Now that I have some familiarity with matplotlib, and I've read the cookbook/wiki page on embedding, I'd like recommendations to sort out my options. I don't need user interaction. On the display side, I have a notebook tab with a panel on which there are a bunch of widgets. These widgets allow the user to specify a curve shape and the characteristics of that curve. A screen shot of this tab is attached. In the available space above the buttons I want to put a small canvas that displays the curve just defined when the 'Save' button is clicked. The x axis is always 0-100, so the individual curve will be displayed in the appropriate position along that axis. The y axis is always 0.0-1.0, and the maximum height of each curve is 1.0. Again, this is strictly for display. The wiki suggests either MPlot or WxMpl for embedding. Which might be preferable for a display-only use? In other words, what would be the simpliest, easiest, most pragmatic approach? Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
Rich Shepard wrote: > The wiki suggests either MPlot or WxMpl for embedding. Which might be > preferable for a display-only use? In other words, what would be the > simpliest, easiest, most pragmatic approach? I think wxMPL is a good option. I think MPlot gives you nifty tools for editing the figure with a GUI, but I don't think you want that. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
On 2007年11月26日, Christopher Barker wrote: > I think wxMPL is a good option. I think MPlot gives you nifty tools for > editing the figure with a GUI, but I don't think you want that. Chris, Thank you. I'll go read about wxMPL then. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> > The wiki suggests either MPlot or WxMpl for embedding. Which might be > preferable for a display-only use? In other words, what would be the > simpliest, easiest, most pragmatic approach? > So far in my experience, and as I was recommended, the "simpliest, easiest, most pragmatic approach" has been to forgo MPlot or WxMpl and just embed directly in wxPython. This page <http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx> discusses the difference between direct embedding and using an embedding library, the key difference for you being this sentence: "An *embedding library* saves you a lot of time and effort by providing plotting widgets that already support user interactions and other bells and whistles." But you don't want such bells and whistles. There is a link on that page to this example<http://www.scipy.org/Matplotlib_figure_in_a_wx_panel>of direct embedding with wx. I was able to start with this and adapt it to my needs.
On 2007年11月26日, C M wrote: > So far in my experience, and as I was recommended, the "simplest, > easiest, most pragmatic approach" has been to forgo MPlot or WxMpl and > just embed directly in wxPython. That is the insight I seek. I've looked at the examples and the cookbook page ... > This page <http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx> > discusses the difference between direct embedding and using an embedding > library, the key difference for you being this sentence: "An *embedding > library* saves you a lot of time and effort by providing plotting widgets > that already support user interactions and other bells and whistles." But > you don't want such bells and whistles. No, I don't need bells or whistles. > There is a link on that page to this > example<http://www.scipy.org/Matplotlib_figure_in_a_wx_panel>of direct > embedding with wx. I was able to start with this and adapt it to my needs. I've looked closely at this, and need to figure out how to translate it from a stand-alone example to working in my application. There's also a reference on that SciPy cookbook page to links to the OO API on the matplotlib FAQ page, but I've not found that link(s). I have the api.pdf but is that the OO one? Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
On 2007年11月26日, Rich Shepard wrote: > A screen shot of this tab is attached. Ah, rats! I forgot to attach it. Here it is. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> > There is a link on that page to this > > example<http://www.scipy.org/Matplotlib_figure_in_a_wx_panel>of direct > > embedding with wx. I was able to start with this and adapt it to my > needs. > > I've looked closely at this, and need to figure out how to translate it > from a stand-alone example to working in my application. > Basically what I did (sorry if this is too basic, but I'm pretty new to this and this may jog others to correct deficiencies in this simple approach) was to: 1. Save the two graphing classes from that example (NoRepaintCanvas and PlotPanel) in their own module for conceptual simplicity and use by various apps I might make. 2. change the draw() method in PlotPanel to a simpler: def draw(self): if not hasattr(self, 'subplot'): self.subplot = self.figure.add_subplot(111) self.subplot.plot(self.xpoints, self.ypoints, marker='o', ms=8, fc='white', mec='blue', mew=1) this isn't great because you cannot change plot characteristics from the GUI yet, but it gets things started (and you may not care). 3. Now the class PlotPanel needs a place to get fed those xpoints and ypoints, so I added it in the __init__, along with a call to draw(). def __init__(self,parent, xpoints=[],ypoints=[] ,id = -1, color = None,\ dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): wx.Panel.__init__(self, parent, id = id, style = style, **kwargs) self.figure = Figure(None, dpi) self.xpoints = xpoints self.ypoints = ypoints self.canvas = NoRepaintCanvas(self, -1, self.figure) self.SetColor(color) self.Bind(wx.EVT_IDLE, self._onIdle) self.Bind(wx.EVT_SIZE, self._onSize) self._resizeflag = True self._SetSize() self.draw() 4. The classes in the module are set. Then in my main app, I made sure to at the top of the app import matplotFrame3 and then just reference this class from there in this method called add_graph... def add_graph(self): if self.graphstate == 1: self.graph.Destroy() ypoints = (10,20,20,33,73) #you'll take this from a list somewhere in your app xpoints = (1,2,3,4,5) #you'll take this from a list somewhere in your app self.graph = matplotFrame3.PlotPanel(self.panel1,xpoints, ypoints) self.boxSizer1.Insert(4, self.graph, 2, border=5, flag=wx.LEFT | wx.TOP |wx.EXPAND) self.boxSizer1.Layout() self.graphstate = 1 This bit about destroying based on the graphstate (exists or doesn't) was just a quick way to prevent adding multiple graphs to the sizer, but I'll clean that up with a better approach later. Hope this gets you further along. > > There's also a reference on that SciPy cookbook page to links to the OO > API on the matplotlib FAQ page, but I've not found that link(s). I have > the > api.pdf but is that the OO one? > That I don't know.
On 2007年11月26日, C M wrote: > Basically what I did (sorry if this is too basic, but I'm pretty new to > this and this may jog others to correct deficiencies in this simple > approach) was to: This is all straightforward and clear. The one statement I've not yet understood is this: > self.graph = matplotFrame3.PlotPanel(self.panel1,xpoints, ypoints) I assume that matplotFrame3 is the name of the module in which you've written PlotPanel(). Is this assumption correct? I'm modifying your approach to suit our application but it seems to be the most parsimonious and elegant solution for simple display of plots in a wxPython panel. Thanks, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
On Nov 27, 2007 11:27 AM, Rich Shepard <rsh...@ap...> wrote: > On 2007年11月26日, C M wrote: > > > Basically what I did (sorry if this is too basic, but I'm pretty new to > > this and this may jog others to correct deficiencies in this simple > > approach) was to: > > This is all straightforward and clear. The one statement I've not yet > understood is this: > > > self.graph = matplotFrame3.PlotPanel(self.panel1,xpoints, > ypoints) > > I assume that matplotFrame3 is the name of the module in which you've > written PlotPanel(). Is this assumption correct? > Exactly. That is the module which I mention importing in step 4. > > I'm modifying your approach to suit our application but it seems to be > the > most parsimonious and elegant solution for simple display of plots in a > wxPython panel. > > Thanks, > Glad it will help your application.
I may be jumping into this conversation way too late, but I really like wxmpl. The one bell and whistle that I love is the click-and-drag box zoom available by default. Attached is my hacked together simple example of putting a wxmpl.PlotPanel on a wx.notebook. Ryan On Nov 27, 2007 11:06 AM, C M <cmp...@gm...> wrote: > > > > On Nov 27, 2007 11:27 AM, Rich Shepard <rsh...@ap...> wrote: > > > > On 2007年11月26日, C M wrote: > > > > > > > Basically what I did (sorry if this is too basic, but I'm pretty new to > > > this and this may jog others to correct deficiencies in this simple > > > approach) was to: > > > > This is all straightforward and clear. The one statement I've not yet > > understood is this: > > > > > > > self.graph = matplotFrame3.PlotPanel(self.panel1 ,xpoints, > ypoints) > > > > I assume that matplotFrame3 is the name of the module in which you've > > written PlotPanel(). Is this assumption correct? > > > > Exactly. That is the module which I mention importing in step 4. > > > > > I'm modifying your approach to suit our application but it seems to be > the > > most parsimonious and elegant solution for simple display of plots in a > > wxPython panel. > > > > Thanks, > > > > > > > > > Glad it will help your application. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
On 2007年11月28日, Ryan Krauss wrote: > I may be jumping into this conversation way too late, but I really like > wxmpl. The one bell and whistle that I love is the click-and-drag box > zoom available by default. Attached is my hacked together simple example > of putting a wxmpl.PlotPanel on a wx.notebook. Ryan, Thank you very much. Our application neither needs nor wants user interaction. The plots are strictly for display. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863