matplotlib question

Tom Wright tew24 at spam.ac.uk
Thu Jun 12 05:21:40 EDT 2008


asdf wrote:
> basically I need to plot a graph of data vs time. However when i use
> matplotlib the hr:min tick marks come out very close together and
> appear jumbled.

You need to look up the matplotlib.dates package - it's covered briefly in
the tutorial at http://matplotlib.sourceforge.net/tutorial.html

At a guess, you want something along the lines of this...

from matplotlib.dates import YearLocator, MonthLocator, WeekdayLocator, \
        DayLocator, HourLocator, MinuteLocator, SecondLocator, \
        DateFormatter

subplot.xaxis.set_major_locator(HourLocator(range(0,24,6)))
subplot.xaxis.set_major_formatter(DateFormatter("%a %H:%M"))
subplot.xaxis.set_minor_locator(HourLocator(range(0,24,1)))

...but you'll probably need to look up the documentation to get the details
to suit what you need.

Hope that helps!


-- 
I'm at CAMbridge, not SPAMbridge



More information about the Python-list mailing list