By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

matplotlib question

P: n/a
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. So 12:00 comes out very close to 12:30 for example.
There are two things I would like to do. First, is to increase
the horizontal dimension of the graph. So basically increase the
horizontal number of pixels. The data will always be from
midnight to midnight it's just that i want it stretched out
more horizontally. Also, how do i specify that i only want hourly
tickmarks. So under the x-axis i only want to see 12:00 1:00 etc.

thanks
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.