On Fri, Jun 10, 2011 at 11:01 AM, calmar c. <m...@calmar.ws> wrote:
> On Fri, Jun 10, 2011 at 09:00:28AM -0400, Scott Lasley wrote:
> >
> > One way would be to use a matplotlib.ticker.FuncFormatter
> >
> > import matplotlib.pyplot as plt
> > import matplotlib.ticker
> >
> > def HMSFormatter(value, loc):
> > h = value // 3600
> > m = (value - h * 3600) // 60
> > s = value % 60
> > return "%02d:%02d:%02d" % (h,m,s)
> >
> > fig = plt.figure()
> > sp = fig.add_subplot(111)
> > xaxis = sp.get_xaxis()
> > xaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(HMSFormatter))
> > seconds = range(12341,12641,30)
> > data = range(10)
> > sp.plot(seconds, data)
> > fig.canvas.draw()
> fig.show() needed here.
>
> Ah ok, great, many thanks.
>
>
> In the case the x is already HH:MM:SS that's a whole other story I
> guess?
>
> anyway,
> cheers
> marco
>
>
Why not just use an array of datetime.timedelta objects? I believe
matplotlib already supports this, does automatic formatting and even allows
you to easily modify how the formatting is done.
Ben Root
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users