Hi, I'm not a frequent user of matplotlib.dates module, so other expert may give you a better answer. My understanding is that, for the date time formatting, the (x-) data needs to be days (if not datetime instance) from some reference point (1, 1, 1? I'm not sure).
The easiest way I can think of in your case is from matplotlib.dates import datetime, SEC_PER_DAY ordinal_today=datetime.datetime.today().toordinal() xvals = ordinal_today + np.arange(1200, dtype="d")/SEC_PER_DAY Also, you'd better comment out the set_minor_locator and set_minot_formatter calls, unless you want the same x-label drawn twice. IHTH, -JJ On Tue, Apr 7, 2009 at 3:47 PM, Brian Zambrano <bri...@gmail.com> wrote: > He there, > > I'm new to matplotlib but have really been appreciating the thorough > documentation and examples online. I've never worked with matlab either so > I'm stumbling my way around a bit, but have managed to get some basic plots > working with my wxPython program. > > I'm plotting some simple time/temp curves. For the time, I have just the > number of seconds, starting at 0 and going up to about 1200 (20 minutes). > I'm trying to format the xaxis so that there is a tick mark every one > minute, and format the tick marks so they display %M:%S. The code below > doesn't give me *any* formatting or tick marks on the xaxis. It seems like > this should be fairly obvious how to accomplish, but I'm not getting it. > > What am I doing wrong here? > > > xvals = range(1200) > yvals = list of temps > > self.mainline = self.ax.plot(xvals, yvals, lw=2, color='red')[0] > > locator = matplotlib.dates.MinuteLocator() > self.ax.xaxis.set_major_locator(locator) > self.ax.xaxis.set_minor_locator(locator) > > formatter = matplotlib.dates.DateFormatter('%M:%S') > self.ax.xaxis.set_major_formatter(formatter) > self.ax.xaxis.set_minor_formatter(formatter) > > # draw the canvas > > > Any help appreciated...thanks! > BZ > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer Now! > http://p.sf.net/sfu/www-ibm-com > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users