[Tutor] question about pylab

Kent Johnson kent37 at tds.net
Tue Oct 31 12:06:09 CET 2006


shawn bright wrote:
> hey there,
> i am trying to use a graph and chart app called matplotlib, but i cannot 
> figgure out how to have it plot a simple chart over time.
> the docs say to use the function plot_date() but i cannot seem to get 
> the values to agree.
> I am sending datetimes to the charting app for x, and the y is a list of 
> values that the our equipment reports.
> sometimes there are lots of reports in a row, and i would like the chart 
> to show it like that instead of plotting out every time as an evenly 
> spaced tick on the x scale. Does this make any sense, what i am after 
> here? Anyway, if any of you have much experience with this sort of 
> thing, or may suggest a package (pylab is my first attempt) please send 
> me some advice.

I have used pylab to create a scatterplot of date vs value. The date 
values were created by calling pylab.date2num() on a datetime.datetime 
value. The axes were set up with this code:

# Set up the xaxis
ax = axes([0.05, 0.05, 0.9, 0.9])

ax.xaxis.set_major_locator(MinuteLocator(interval=10))
ax.xaxis.set_minor_locator(MinuteLocator())
ax.xaxis.set_major_formatter(DateFormatter("%H:%M"))


I called pylab.scatter() to create the plot.

HTH,
Kent



More information about the Tutor mailing list