Skip to content

Instantly share code, notes, and snippets.

@categulario
Created September 25, 2020 23:34
Show Gist options
  • Save categulario/1b499ef2fe524b2e93fe3e6a7c8124a7 to your computer and use it in GitHub Desktop.
Save categulario/1b499ef2fe524b2e93fe3e6a7c8124a7 to your computer and use it in GitHub Desktop.
Diagrama Xalapa
44.4,46.7,41.4,65.9,110.8,278,206.1,164.9,255,89.4,58.7,50
15.7,16.6,18.8,21.1,22,21.7,20.7,20.8,20.4,19.3,17.8,16.4
Diagrama Perote
13.3,14.2,11.1,26.2,34.8,74.9,53.3,54.6,110.8,76,24.8,13.8
9.9,10.9,13.3,14.9,15.4,14.7,13.6,13.4,13.4,12,10.7,12.7
Diagrama Paso de ovejas
14.8,10.2,8.6,10.6,32.3,172.6,239,180.5,161.3,61.2,27.8,14.7
21.4,22.2,24.3,26.7,28.2,28.1,26.7,26.9,26.9,25.8,24.2,22.1
Diagrama las Vigas
30.3,31.5,23.6,39.3,52.8,155.9,155.2,140.6,244.5,143.3,71.5,36.2
9.3,10.5,12.5,14.1,14.7,13.4,12.4,12.5,12,11.1,10.4,9.6
import matplotlib.pyplot as plt
import sys
import csv
meses = [ 'enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre', ]
colors = [
'red',
'green',
'blue',
'orange',
]
def main(data):
fig, ax = plt.subplots()
fig.suptitle('Termohietica', fontsize=14)
for i, chunk in enumerate(data):
for month in range(11):
ax.annotate(meses[month], xy=(chunk['prec'][month], chunk['temp'][month]))
plt.plot(chunk['prec'][month:month+2], chunk['temp'][month:month+2], color=colors[i], marker='o', linestyle='solid')
ax.annotate(meses[11], xy=(chunk['prec'][11], chunk['temp'][11]))
plt.plot([chunk['prec'][0], chunk['prec'][11]], [chunk['temp'][0], chunk['temp'][11]], color=colors[i], marker='o', linestyle='solid')
ax.set_xlabel('Precipitación')
ax.set_ylabel('Temperatura')
plt.show()
def get_row(line):
if line.startswith('\ufeff'):
line = line[1:]
return list(map(lambda x: float(x.strip()), line.strip().split(',')))
if __name__ == '__main__':
try:
filename = sys.argv[1]
except IndexError:
print("Se te olvidó pasarle el nombre del archivo de datos")
with open(filename) as datafile:
data = [
{
'title': next(datafile)[0],
'prec': get_row(next(datafile)),
'temp': get_row(next(datafile)),
}
for _ in range(4)
]
main(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment