Trop de date avec NumPy ?
Bonjour,
J'utilise le code ci-dessous pour tracer à partir d'un fichier une courbe.
Le fichier à la forme suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Date;Conso
29/09/2010;22731.0
08/11/2010;14796.0
30/11/2010;21137.0
10/04/2010;19854.0
18/05/2010;18755.0
15/04/2010;17275.0
28/08/2010;21659.0
19/04/2010;18922.0
25/02/2010;18199.0
02/09/2010;26234.0
08/05/2010;16858.0
25/05/2010;21927.0
... |
la dernière date est au 31/01/2011.
le code est le suivant :
Code:
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() |
or dans le tracé j'ai des dates jusqu'à fin 2011 et donc supérieur au 31/01/2011. Je ne trouve pas mon erreur.
Merci de votre aide