1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| np_rec_array = mlab.csv2rec(repOri + 'temp_top10.csv', delimiter=';' )
np_rec_array.sort() # in-place sort
print np_rec_array
# a `figure` is a starting point for MPL visualizations
fig = plt.figure( figsize=(15,10) )
# add a set of `axes` to above `figure`
ax = fig.add_subplot(111)
x = np_rec_array.date
print x
y = np_rec_array.conso
# `plot_date` is like `plot` but allows for easier x-axis formatting
ax.plot_date(x, y, 'o-', color='g')
# show date every interval
ax.xaxis.set_major_locator( mdates.DayLocator(interval=10) )
# specify time format
ax.xaxis.set_major_formatter(mdates.DateFormatter("%d/%m/%Y") )
# set x-axis label rotation (otherwise they can overlap)
for l in ax.get_xticklabels():
l.set_rotation(60)
plt.title( 'Consommation' )
plt.show() |
Partager