[Matplotlib-users] x-axes time format
Hi all, what could be a simple way when I have 'seconds' as data to display them as %H:%M:%S on the x-axes? many thanks marco -- (o_ It rocks: LINUX + Command-Line-Interface //\ GPG: 0x59D90F4D V_/_ http://www.calmar.ws -- 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
Re: [Matplotlib-users] x-axes time format
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 -- (o_ It rocks: LINUX + Command-Line-Interface //\ GPG: 0x59D90F4D V_/_ http://www.calmar.ws -- 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
Re: [Matplotlib-users] x-axes time format
On Fri, Jun 10, 2011 at 11:10:02AM -0500, Benjamin Root wrote: > >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. I was not able to figure out how it would support them (datetime.timedelta objects). datetime.datetime objects only as far as I saw. So I would have to create some artificial datetime + add the timedeltas (seconds) to it and providing that to the plot I guess, right? So far the solution to just show i.e. 70sec as 00:01:20 via some little function is almost more sympathetic to me (so far at least). Cheers and thanks, marco -- (o_ It rocks: LINUX + Command-Line-Interface //\ GPG: 0x59D90F4D V_/_ http://www.calmar.ws -- 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
Re: [Matplotlib-users] x-axes time format
On Fri, Jun 10, 2011 at 10:50:21PM -0500, Benjamin Root wrote: Hi Ben and Scott and all, >Admittedly, these following examples are for dates (and might even need to >be updated...) >[2]http://matplotlib.sourceforge.net/examples/api/date_demo.html >[3]http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html > >There are others as well. I see, thanks (all your examples here are pretty helpful for understanding matplotlib somebit better - even so I'm using the Formatter-Function now). marco -- (o_ It rocks: LINUX + Command-Line-Interface //\ GPG: 0x59D90F4D V_/_ http://www.calmar.ws -- 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