On Tue, May 27, 2008 at 2:14 PM, Margherita Vittone wiersma
<[EMAIL PROTECTED]> wrote:

> id_list=[1,2,3,4,5,6]
> str_dates=['2006-07-29 11:01:01','2006-07-29 10:02:03','2006-07-31 00:00:00',
>          '2006-08-01 10:11:12','2006-08-02 09:09:09','2006-08-03 08:08:08']
>
> id_dates=datestr2num(str_dates)
>
> # It appears to ignore the formatting, it shows the month,day and year but 
> not the time...
> formatter = DateFormatter('%m-%d-%y %H:%M:%S')
>
> ax = subplot(111)
> ax.plot_date(id_dates,id_list)
> ax.xaxis.set_major_formatter(dateFormatter)

"dateFormatter" is not defined -- I think you mean "formatter"

When I run this example with this change, I get tick labels with the
hour, minute and second as indicated...

Note recent versions of maptlotlib can takes dates explicitly (it will
handle the conversion for you).  I would write this example as
(fig.autofmt_xdate will handle the ticklabel rotation for you)

import datetime
import dateutil.parser
import matplotlib.dates as mpldates
import matplotlib.pyplot as plt

ids = [1,2,3,4,5,6]
str_dates = ['2006-07-29 11:01:01','2006-07-29 10:02:03','2006-07-31 00:00:00',
             '2006-08-01 10:11:12','2006-08-02 09:09:09','2006-08-03 08:08:08']

dates = [dateutil.parser.parse(s) for s in str_dates]

formatter = mpldates.DateFormatter('%m-%d-%y %H:%M:%S')

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(dates, ids, 'o')
ax.xaxis.set_major_formatter(formatter)

fig.autofmt_xdate()
ax.set_title("test dates")
plt.show()



JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to