matplotlib question

A

asdf

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
 
T

Tom Wright

asdf said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top