Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Eric Firing <efiring@ha...>  20070905 07:46:36

C M wrote: [...] > So basically I need to use plot_date but in a figure embedded in a > wxPython app. > Still not sure how this should be written. To make it simple, this > plot() command > works in my app already: > > x = [1,2,3] > y = [10,20,30] > self.subplot.plot(x, y) I don't understandwhere did "self" come from? If we assume that self.subplot is in fact an axes instance, then you can use self.subplot.plot_date(...), where the arguments would be the same as if you were using pylab.plot_date(...). All this might be clarified if you look at the code for pylab.plot and pylab.plot_date. I may be missing something; I was not paying attention to earlier parts of this thread, I haven't done much with dates and have never used plot_date myself, and I have no experience with embedding. Maybe it would also help for you to look at dates.py (one of the mpl modules)? Eric > > So, my question is, how would this be modified for a wx app (that is, no > pylab > allowed) and use plot_date()? Assume my dates are as given below. > > dates (x axis): > 090107 12:00:02 > 090207 12:00:04 > 090307 12:00:06 > > values (y axis): > 10 > 20 > 30 > > The examples that Bill and Mark gave above in the list showed how to do > this using pylab, but I just need the simplest example and one which does > not use pylab. > > Thanks, > Che > 
From: Mark Bakker <markbak@gm...>  20070904 15:20:37
Attachments:
Message as HTML

Maybe this will get you going: import pylab as p import datetime as d from matplotlib.dates import DateFormatter t = [ d.datetime (2007,9,1,12), d.datetime(2007,9,2,12), d.datetime(2007,9,3,12) ] t = p.date2num(t) p.plot_date( t, [10,20,30] ) p.xticks(t) y = DateFormatter('%Y%m%d') p.gca().xaxis.set_major_formatter(y) p.draw() Mark From: "C M" <cmpython@...> > Subject: [Matplotlibusers] basic understanding of plotting dates > > x = (20070901 12:00:02, 20070902 12:00:02, 20070903 12:00:02) > y = (10, 20, 30) > 
From: C M <cmpython@gm...>  20070904 21:45:59
Attachments:
Message as HTML

Mark, Mark, Brendan, John, thanks for the input. I have a related question that may help to continue to clear things up for me. My goal is to use matplotlib with wxPython, and I've been able to embed graphs in wxPython apps fine so far (in this case, directly, not using wxMPL). What I wanted to know is whether it is necessary to use pylab or not. I am a little unclear what the purpose of pylab is in distinction to matplotlib itself. I gather that pylab is a way to sort of emulate Matlab, but I am unclear as to whether I need to be using pylab in my apps or not. I am not doing scientific plots, just fairly simple graphs, though I may throw some regression lines and r values on there at some point. I really just want to keep things as simple as possible, and if I don't need to use pylab, I'd rather not. Any insight would be helpful. Thank you. Che M On 9/4/07, Mark Bakker <markbak@...> wrote: > > Maybe this will get you going: > > import pylab as p > import datetime as d > from matplotlib.dates import DateFormatter > t = [ d.datetime (2007,9,1,12), d.datetime(2007,9,2,12), d.datetime(2007,9,3,12) > ] > t = p.date2num(t) > p.plot_date( t, [10,20,30] ) > p.xticks(t) > y = DateFormatter('%Y%m%d') > p.gca().xaxis.set_major_formatter(y) > p.draw() > > Mark > > From: "C M" <cmpython@...> > > Subject: [Matplotlibusers] basic understanding of plotting dates > > > > x = (20070901 12:00:02, 20070902 12:00:02, 20070903 12:00:02) > > y = (10, 20, 30) > > > > 
From: C M <cmpython@gm...>  20070904 22:48:38
Attachments:
Message as HTML

I realize that the clearer question (and one which ties into my original thread) is: do I need pylab to do plot_date()? On 9/4/07, C M <cmpython@...> wrote: > > Mark, Mark, Brendan, John, thanks for the input. I have a related > question that may help to continue to clear things up for me. My goal is to > use matplotlib with wxPython, and I've been able to embed graphs in wxPython > apps fine so far (in this case, directly, not using wxMPL). What I wanted > to know is whether it is necessary to use pylab or not. I am a little > unclear what the purpose of pylab is in distinction to matplotlib itself. I > gather that pylab is a way to sort of emulate Matlab, but I am unclear as to > whether I need to be using pylab in my apps or not. I am not doing > scientific plots, just fairly simple graphs, though I may throw some > regression lines and r values on there at some point. > > I really just want to keep things as simple as possible, and if I don't > need to use pylab, I'd rather not. Any insight would be helpful. Thank > you. > Che M > > On 9/4/07, Mark Bakker <markbak@...> wrote: > > > > Maybe this will get you going: > > > > import pylab as p > > import datetime as d > > from matplotlib.dates import DateFormatter > > t = [ d.datetime (2007,9,1,12), d.datetime(2007,9,2,12), d.datetime(2007,9,3,12) > > ] > > t = p.date2num(t) > > p.plot_date( t, [10,20,30] ) > > p.xticks(t) > > y = DateFormatter('%Y%m%d') > > p.gca().xaxis.set_major_formatter(y) > > p.draw() > > > > Mark > > > > From: "C M" <cmpython@...> > > > Subject: [Matplotlibusers] basic understanding of plotting dates > > > > > > x = (20070901 12:00:02, 20070902 12:00:02, 20070903 12:00:02) > > > y = (10, 20, 30) > > > > > > > > 
From: Mark Bakker <markbak@gm...>  20070905 07:45:34
Attachments:
Message as HTML

Hey Che  If you include your graphs in a wxPython app, you shouldn't use pylab. Pylab is a wrapper to (quickly) generate graphs, and is very useful, especially in interactive mode, as it saves a lot of typing and is much easier to understand (indeed, a lot like matlab plotting). But for inclusion in apps you need to use matplotlib, so you are on the right track. This has been discussed several times on the list, but it may not be so easy to find. Maybe we should put this on the FAQ page (or maybe it is already there!), Mark On 9/4/07, C M <cmpython@...> wrote: > > Mark, Mark, Brendan, John, thanks for the input. I have a related > question that may help to continue to clear things up for me. My goal is to > use matplotlib with wxPython, and I've been able to embed graphs in wxPython > apps fine so far (in this case, directly, not using wxMPL). What I wanted > to know is whether it is necessary to use pylab or not. I am a little > unclear what the purpose of pylab is in distinction to matplotlib itself. I > gather that pylab is a way to sort of emulate Matlab, but I am unclear as to > whether I need to be using pylab in my apps or not. I am not doing > scientific plots, just fairly simple graphs, though I may throw some > regression lines and r values on there at some point. > > I really just want to keep things as simple as possible, and if I don't > need to use pylab, I'd rather not. Any insight would be helpful. Thank > you. > Che M > > On 9/4/07, Mark Bakker <markbak@...> wrote: > > > > Maybe this will get you going: > > > > import pylab as p > > import datetime as d > > from matplotlib.dates import DateFormatter > > t = [ d.datetime (2007,9,1,12), d.datetime(2007,9,2,12), d.datetime(2007,9,3,12) > > ] > > t = p.date2num(t) > > p.plot_date( t, [10,20,30] ) > > p.xticks(t) > > y = DateFormatter('%Y%m%d') > > p.gca().xaxis.set_major_formatter(y) > > p.draw() > > > > Mark > > > > From: "C M" <cmpython@...> > > > Subject: [Matplotlibusers] basic understanding of plotting dates > > > > > > x = (20070901 12:00:02, 20070902 12:00:02, 20070903 12:00:02) > > > y = (10, 20, 30) > > > > > > > > 
From: Eric Firing <efiring@ha...>  20070904 22:55:54

C M wrote: > Mark, Mark, Brendan, John, thanks for the input. I have a related > question that may help to continue to clear things up for me. My goal > is to use matplotlib with wxPython, and I've been able to embed graphs > in wxPython apps fine so far (in this case, directly, not using wxMPL). > What I wanted to know is whether it is necessary to use pylab or not. I > am a little unclear what the purpose of pylab is in distinction to > matplotlib itself. I gather that pylab is a way to sort of emulate > Matlab, but I am unclear as to whether I need to be using pylab in my > apps or not. I am not doing scientific plots, just fairly simple > graphs, though I may throw some regression lines and r values on there > at some point. > > I really just want to keep things as simple as possible, and if I don't > need to use pylab, I'd rather not. Any insight would be helpful. Thank > you. > Che M No, you do not need to use pylab. It provides an API that is concise, comfortable, and responsive, especially for interactive use. Even in scripts that are mostly written in OO fashion, use of a few pylab functions (e.g., figure, subplot, show) can simplify the code. This does not apply if you are embedding mpl in wx, however; none of the examples/embedding_in_*.py demos import pylab. In addition to its role as an alternative interface to mpl, pylab imports most of numpy and some additional functions, providing a somewhat matlablike environment. This can be handy for interactive work. There is a range of opinion regarding pylab, but I think the center of the range is: don't use pylab when mpl is embedded; use it very sparingly for normal programming; and for interactive use, if it makes you more productive, use it as much as you want. Eric 
From: Eric Firing <efiring@ha...>  20070904 22:57:55

C M wrote: > I realize that the clearer question (and one which ties into my original > thread) is: do I need pylab to do plot_date()? No, plot_date is available as an axes method. Most pylab plotting commands are thin wrappers for axes methods. Eric 
From: C M <cmpython@gm...>  20070905 07:00:31
Attachments:
Message as HTML

On 9/4/07, Eric Firing <efiring@...> wrote: > > C M wrote: > > I realize that the clearer question (and one which ties into my original > > thread) is: do I need pylab to do plot_date()? > > No, plot_date is available as an axes method. Most pylab plotting > commands are thin wrappers for axes methods. Thanks for your help in clearing this up and the uses of pylab. So basically I need to use plot_date but in a figure embedded in a wxPython app. Still not sure how this should be written. To make it simple, this plot() command works in my app already: x = [1,2,3] y = [10,20,30] self.subplot.plot(x, y) So, my question is, how would this be modified for a wx app (that is, no pylab allowed) and use plot_date()? Assume my dates are as given below. dates (x axis): 090107 12:00:02 090207 12:00:04 090307 12:00:06 values (y axis): 10 20 30 The examples that Bill and Mark gave above in the list showed how to do this using pylab, but I just need the simplest example and one which does not use pylab. Thanks, Che 
From: Eric Firing <efiring@ha...>  20070905 07:46:36

C M wrote: [...] > So basically I need to use plot_date but in a figure embedded in a > wxPython app. > Still not sure how this should be written. To make it simple, this > plot() command > works in my app already: > > x = [1,2,3] > y = [10,20,30] > self.subplot.plot(x, y) I don't understandwhere did "self" come from? If we assume that self.subplot is in fact an axes instance, then you can use self.subplot.plot_date(...), where the arguments would be the same as if you were using pylab.plot_date(...). All this might be clarified if you look at the code for pylab.plot and pylab.plot_date. I may be missing something; I was not paying attention to earlier parts of this thread, I haven't done much with dates and have never used plot_date myself, and I have no experience with embedding. Maybe it would also help for you to look at dates.py (one of the mpl modules)? Eric > > So, my question is, how would this be modified for a wx app (that is, no > pylab > allowed) and use plot_date()? Assume my dates are as given below. > > dates (x axis): > 090107 12:00:02 > 090207 12:00:04 > 090307 12:00:06 > > values (y axis): > 10 > 20 > 30 > > The examples that Bill and Mark gave above in the list showed how to do > this using pylab, but I just need the simplest example and one which does > not use pylab. > > Thanks, > Che > 
From: C M <cmpython@gm...>  20070905 18:24:55
Attachments:
Message as HTML

> x = [1,2,3] > > y = [10,20,30] > > self.subplot.plot(x, y) > > I don't understandwhere did "self" come from? Sorry"self" here refers to an instance of a wxPanel class in my wxPython app. It is the parent window for the mpl subplot which is meant to be a child of it. The subplot is itself a child of a Figure, so the creation is like this: self.figure = Figure(None, dpi) self.subplot = self.figure.add_subplot(111) If we assume that self.subplot is in fact an axes instance, then you can > use > self.subplot.plot_date(...), where the arguments would be the same as if > you were using pylab.plot_date(...). Is it? How is Figure() related to axes? Maybe it would also help for you to look at dates.py (one of the mpl > modules)? I will try; so far, when I try to adapt the examples given in this thread to an wx embedded app it is not working... Thanks, Che 
From: Eric Firing <efiring@ha...>  20070905 19:05:56

C M wrote: > > > > x = [1,2,3] > > y = [10,20,30] > > self.subplot.plot(x, y) > > I don't understandwhere did "self" come from? > > > Sorry"self" here refers to an instance of a wxPanel class in my > wxPython app. > It is the parent window for the mpl subplot which is meant to be a child > of it. > The subplot is itself a child of a Figure, so the creation is like this: > > self.figure = Figure(None, dpi) > self.subplot = self.figure.add_subplot(111) add_subplot makes an Axes instance and puts it in the Figure instance; self.subplot is this Axes instance, as I had guessed. So, you can apply any Axes method to it. Eric 
Sign up for the SourceForge newsletter:
No, thanks