generate.py
· 1.2 KiB · Python
Eredeti
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
Para geração de histograma dos tempos de queda
'''
import sys
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# Tamanho da página do histograma
width = 20 # cm
height = 15 # cm
if len(sys.argv) < 4:
print "Usage: generate.py data.txt title output"
exit(1)
output = sys.argv[3]
title = sys.argv[2].decode(encoding='UTF-8',errors='strict')
data = np.fromfile(sys.argv[1], sep='\n')
num_bins = 12
avg = np.average(data)
std = np.std(data)
fig, ax = plt.subplots()
n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled')
print "Média: %s Desvio Padrão: %s" %(avg, std)
ax.axvline(avg, color='red', label="Média = %.2f s" %avg)
ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f s" %(avg-std))
ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f s" % (avg+std))
ax.set_xlabel('Tempo (s)')
ax.set_ylabel('Contagem (n)')
ax.set_title(title)
ax.set_ylim( None, n.max() * 1.2)
legend = ax.legend(loc='upper left', shadow=True, prop={'size':10})
fig.tight_layout()
fig.set_size_inches(width / 2.54, height / 2.54)
plt.savefig('%s.png' %output, dpi=100)
| 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | from __future__ import unicode_literals |
| 4 | |
| 5 | ''' |
| 6 | Para geração de histograma dos tempos de queda |
| 7 | ''' |
| 8 | |
| 9 | import sys |
| 10 | import numpy as np |
| 11 | import matplotlib.mlab as mlab |
| 12 | import matplotlib.pyplot as plt |
| 13 | |
| 14 | # Tamanho da página do histograma |
| 15 | width = 20 # cm |
| 16 | height = 15 # cm |
| 17 | |
| 18 | if len(sys.argv) < 4: |
| 19 | print "Usage: generate.py data.txt title output" |
| 20 | exit(1) |
| 21 | |
| 22 | output = sys.argv[3] |
| 23 | title = sys.argv[2].decode(encoding='UTF-8',errors='strict') |
| 24 | |
| 25 | data = np.fromfile(sys.argv[1], sep='\n') |
| 26 | |
| 27 | num_bins = 12 |
| 28 | avg = np.average(data) |
| 29 | std = np.std(data) |
| 30 | |
| 31 | fig, ax = plt.subplots() |
| 32 | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') |
| 33 | |
| 34 | print "Média: %s Desvio Padrão: %s" %(avg, std) |
| 35 | |
| 36 | ax.axvline(avg, color='red', label="Média = %.2f s" %avg) |
| 37 | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f s" %(avg-std)) |
| 38 | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f s" % (avg+std)) |
| 39 | |
| 40 | ax.set_xlabel('Tempo (s)') |
| 41 | ax.set_ylabel('Contagem (n)') |
| 42 | ax.set_title(title) |
| 43 | ax.set_ylim( None, n.max() * 1.2) |
| 44 | |
| 45 | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) |
| 46 | fig.tight_layout() |
| 47 | |
| 48 | fig.set_size_inches(width / 2.54, height / 2.54) |
| 49 | plt.savefig('%s.png' %output, dpi=100) |
grafa.py
· 1.3 KiB · Python
Eredeti
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
Para geração de histograma das acelerações
'''
import sys
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# Tamanho da página do histograma
width = 20 # cm
height = 15 # cm
# Altura de queda
deltaS = 34 # metros
if len(sys.argv) < 3:
print "Usage: generate.py data.txt output"
exit(1)
output = sys.argv[2]
data = np.fromfile(sys.argv[1], sep='\n')
data = (2 * deltaS) / (data ** 2)
num_bins = 12
avg = np.average(data)
std = np.std(data)
fig, ax = plt.subplots()
n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled')
print "Média: %s Desvio Padrão: %s" %(avg, std)
ax.axvline(avg, color='red', label="Média = %.2f m/s²" %avg)
ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s²" %(avg-std))
ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s²" % (avg+std))
ax.set_xlabel('Aceleração (m/s²)')
ax.set_ylabel('Contagem (n)')
ax.set_title('Histograma das Acelerações Médias')
ax.set_ylim( None, n.max() * 1.2)
legend = ax.legend(loc='upper left', shadow=True, prop={'size':10})
fig.tight_layout()
fig.set_size_inches(width / 2.54, height / 2.54)
plt.savefig('%s.png' %output, dpi=100)
| 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | from __future__ import unicode_literals |
| 4 | |
| 5 | ''' |
| 6 | Para geração de histograma das acelerações |
| 7 | ''' |
| 8 | |
| 9 | import sys |
| 10 | import numpy as np |
| 11 | import matplotlib.mlab as mlab |
| 12 | import matplotlib.pyplot as plt |
| 13 | |
| 14 | # Tamanho da página do histograma |
| 15 | width = 20 # cm |
| 16 | height = 15 # cm |
| 17 | |
| 18 | # Altura de queda |
| 19 | deltaS = 34 # metros |
| 20 | |
| 21 | if len(sys.argv) < 3: |
| 22 | print "Usage: generate.py data.txt output" |
| 23 | exit(1) |
| 24 | |
| 25 | output = sys.argv[2] |
| 26 | |
| 27 | data = np.fromfile(sys.argv[1], sep='\n') |
| 28 | |
| 29 | data = (2 * deltaS) / (data ** 2) |
| 30 | |
| 31 | num_bins = 12 |
| 32 | avg = np.average(data) |
| 33 | std = np.std(data) |
| 34 | |
| 35 | fig, ax = plt.subplots() |
| 36 | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') |
| 37 | |
| 38 | print "Média: %s Desvio Padrão: %s" %(avg, std) |
| 39 | |
| 40 | ax.axvline(avg, color='red', label="Média = %.2f m/s²" %avg) |
| 41 | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s²" %(avg-std)) |
| 42 | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s²" % (avg+std)) |
| 43 | |
| 44 | ax.set_xlabel('Aceleração (m/s²)') |
| 45 | ax.set_ylabel('Contagem (n)') |
| 46 | ax.set_title('Histograma das Acelerações Médias') |
| 47 | ax.set_ylim( None, n.max() * 1.2) |
| 48 | |
| 49 | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) |
| 50 | fig.tight_layout() |
| 51 | |
| 52 | fig.set_size_inches(width / 2.54, height / 2.54) |
| 53 | plt.savefig('%s.png' %output, dpi=100) |
grafv.py
· 1.3 KiB · Python
Eredeti
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
Para geração de histograma das velocidades
'''
import sys
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# Tamanho da página do histograma
width = 20 # cm
height = 15 # cm
# Altura de queda
deltaS = 34 # metros
if len(sys.argv) < 3:
print "Usage: generate.py data.txt output"
exit(1)
output = sys.argv[2]
data = np.fromfile(sys.argv[1], sep='\n')
data = deltaS / data
num_bins = 12
avg = np.average(data)
std = np.std(data)
fig, ax = plt.subplots()
n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled')
print "Média: %s Desvio Padrão: %s" %(avg, std)
ax.axvline(avg, color='red', label="Média = %.2f m/s" %avg)
ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s" %(avg-std))
ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s" % (avg+std))
ax.set_xlabel('Velocidade (m/s)')
ax.set_ylabel('Contagem (n)')
ax.set_title('Histograma das Velocidades Médias')
ax.set_ylim( None, n.max() * 1.2)
legend = ax.legend(loc='upper left', shadow=True, prop={'size':10})
fig.tight_layout()
fig.set_size_inches(width / 2.54, height / 2.54)
plt.savefig('%s.png' %output, dpi=100)
| 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | from __future__ import unicode_literals |
| 4 | |
| 5 | ''' |
| 6 | Para geração de histograma das velocidades |
| 7 | ''' |
| 8 | |
| 9 | import sys |
| 10 | import numpy as np |
| 11 | import matplotlib.mlab as mlab |
| 12 | import matplotlib.pyplot as plt |
| 13 | |
| 14 | # Tamanho da página do histograma |
| 15 | width = 20 # cm |
| 16 | height = 15 # cm |
| 17 | |
| 18 | # Altura de queda |
| 19 | deltaS = 34 # metros |
| 20 | |
| 21 | if len(sys.argv) < 3: |
| 22 | print "Usage: generate.py data.txt output" |
| 23 | exit(1) |
| 24 | |
| 25 | output = sys.argv[2] |
| 26 | |
| 27 | data = np.fromfile(sys.argv[1], sep='\n') |
| 28 | |
| 29 | data = deltaS / data |
| 30 | |
| 31 | num_bins = 12 |
| 32 | avg = np.average(data) |
| 33 | std = np.std(data) |
| 34 | |
| 35 | fig, ax = plt.subplots() |
| 36 | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') |
| 37 | |
| 38 | print "Média: %s Desvio Padrão: %s" %(avg, std) |
| 39 | |
| 40 | ax.axvline(avg, color='red', label="Média = %.2f m/s" %avg) |
| 41 | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s" %(avg-std)) |
| 42 | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s" % (avg+std)) |
| 43 | |
| 44 | ax.set_xlabel('Velocidade (m/s)') |
| 45 | ax.set_ylabel('Contagem (n)') |
| 46 | ax.set_title('Histograma das Velocidades Médias') |
| 47 | ax.set_ylim( None, n.max() * 1.2) |
| 48 | |
| 49 | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) |
| 50 | fig.tight_layout() |
| 51 | |
| 52 | fig.set_size_inches(width / 2.54, height / 2.54) |
| 53 | plt.savefig('%s.png' %output, dpi=100) |