plot duration given format of '3:04:02.994000'

This a time duration in my database: '3:04:02.994000' (i.e., 3 hrs, 4
min, 2 sec and 994 microsec). It's a string.

Is there a way to allow Matplotlib to interpret that directly as a
duration of time?

Thank you.

` I have been able to embed a matplotlib simple line graph into a
wxpython application and then dynamically update the underlying
line data.

  However, I now want to do something similar with an errorbar

plot. I see that the errorbar() call returns (plotline ,
caplines, barlinecols ) where ‘plotline’
describes the line part of the plot and the ‘caplines’ and
‘barlinecols’ describe the error bars and use the Path object.

  I just can't see how to change the values underlying the

errorbars. I need to change the x and y values as well as the
yerr values.

  Anybody have any idea how to do this?  Or should I look at other

approaches, such a simple line graph and a patch that draws error
bars ‘by hand’?

  Thanks,

  Ross

`

I have been able to embed a matplotlib simple line graph into a wxpython
application and then dynamically update the underlying line data.

However, I now want to do something similar with an errorbar plot. I see
that the errorbar() call returns (/plotline/, /caplines/, /barlinecols/)
where 'plotline' describes the line part of the plot and the 'caplines'
and 'barlinecols' describe the error bars and use the Path object.

I just can't see how to change the values underlying the errorbars. I
need to change the x and y values as well as the yerr values.

Anybody have any idea how to do this? Or should I look at other
approaches, such a simple line graph and a patch that draws error bars
'by hand'?

If you need to update everything, then you probably can't do much better than to simply clear the axes and call the errorbar method each time you need to update. That is certainly the easy way--you might as well try it first.

Eric

···

On 07/17/2011 03:47 PM, r-w wrote:

Thanks,
Ross

` Thanks for the tip Eric. It would work but I probably don’t
want to go that way as the application I’m working on will have up
to 25 line plots as well as other adornments. But your suggestion
lead me to another approach - put errorbars on a graph as a patch
and remove the patch and create a new patch whenever the errorbar
data changes.

  I got most of the patch code from the tutorial:

  A working example is at:

Not sure if the above approach will work in my ‘production’
widget, but I’m on my way!
Thanks,
Ross
`

···

plotline//caplines//barlinecols//> > >> > >> > > http://matplotlib.sourceforge.net/users/path_tutorial.html

http://pastebin.com/KMzzFTCi

Hi,

why don't you just parse the returned string?

asdf = '3:04:02.994000'
asdf = asdf.split(':')
temp = asdf[-1].split('.')
print asdf
asdf.pop(-1)
print asdf
asdf.extend(temp)
print asdf
asdf = [int(i) for i in asdf]
print asdf
hrs,mins,secs,usecs = asdf

That should work, and you can always transform this into some common
unit, e.g. seconds etc.

Hope it helps,
Daniel

2011/7/17 C M <cmpython@...287...>:

···

This a time duration in my database: '3:04:02.994000' (i.e., 3 hrs, 4
min, 2 sec and 994 microsec). It's a string.

Is there a way to allow Matplotlib to interpret that directly as a
duration of time?

Thank you.

Thanks. The issue, though is that I don't want to display a graph
with seconds, but with whatever units is most suitable, since my data
is going to range from seconds to hours. If most datapoints are
hours, I don't want things expressed in terms of "5000 seconds".

I thought there might be a way to use a DateLocator or DateFormatter
with this kind of data so that it could pick the most suitable units
based on a standardized time duration string.

So do people think I have to create my own custom locator or formatter
to do this?

Thanks,
Che

···

On Mon, Jul 18, 2011 at 10:58 AM, Daniel Mader <danielstefanmader@...982...> wrote:

Hi,

why don't you just parse the returned string?

asdf = '3:04:02.994000'
asdf = asdf.split(':')
temp = asdf[-1].split('.')
print asdf
asdf.pop(-1)
print asdf
asdf.extend(temp)
print asdf
asdf = [int(i) for i in asdf]
print asdf
hrs,mins,secs,usecs = asdf

That should work, and you can always transform this into some common
unit, e.g. seconds etc.