1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| def plot_1d (cities):
"""
visualize temperature in the first city
for all available dates
"""
# find the first selected city
city = None
for c in cities:
if 'selected' in c:
city = c
if not city:
print('No city selected for plot_1d')
return
points_per_day = ('morn',)
#points_per_day = ('morn', 'day', 'eve', 'night')
nb_per_day = len(points_per_day)
T = [ measure['rain']
for measure in city['data']
]
X = range(1,4*(len(T))+1,4)
print (X)
bar_plot = plot.plot(X, T, linewidth=4)
plot.ylabel(u'mm')
plot.title(u'Pluie in {}'.format(xpath(city, 'city/name')))
D = [ date_repr(measure['dt']) for measure in city['data'] ]
Dx = [ 4*n+2 for n in range(len(city['data']))]
plot.xticks(Dx, D, rotation='vertical')
#plot.yticks(np.arange(0,81,10))
#plot.legend( (p1[0], p2[0]), ('Men', 'Women') )
plot.show() |