[Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
Hi, We have been working on a python wx app GUI for finding and selecting metadata (lots of lists and check boxes) from a test (that later fetches SQL time-history data for further processing in LabView or elsewhere). As an afterthought, we decided to add in a small function that would allow previewing (plotting) of time-history data based on the selected metadata. The objective is to have a window pop up with the plotted time history data and allow the user to zoom, scroll etc, without closing or exiting the original GUI for selecting the metadata. The reason I want a pop up window is because I don't want to change the original metadata selection GUI (it's too complicated) What I've done so far is: Added a button to the metadata GUI called plot. In the OnPlotButton event handler I embedded the plotting code. The plot button works fine when I click it the first time. However, problems occur when I decide to plot a different set of data (without starting over the metadata GUI). I'd like to choose some new metadata, then click on the plot button again. But as of present, this causes the figure to show a gray image (no lines plotted) and then both GUIs hang up. I've tried closing the figure manually prior to selecting new metadata and clicking on plot but it still causes the metadata GUI to lock up. Based on what I've been reading regarding MPL, it seems that the matplotlib show() function causes another instance of a GUI loop to remain suspended. Is there any way to get the pop-up figure to show the time-history data and remain interactive (zoom, scroll, etc) and be able to re-plot or replace the current plot? I thought about using the draw() function but I couldn't get it to pop-up the figure. Also, if I'm not mistaken, the draw() function doesn't allow for interactive control? I think this issue is similar to the issue described here: http://mail.python.org/pipermail/pythonmac-sig/2005-March/013365.html but I can't seem to find a simple solution, without embedding the plot figure directly into the existing GUI (not something easy to do as I'm not a very experienced Python programmer) Please let me know if anyone can help. Here is my code: def OnPlotButton(self, event): global SelTestID, SelRunList, SelEventID, SelChanList, SelCycList if self.notebook.GetSelection() == 0: SelTestID = self.listCtrlStatus.GetItem(0,1).GetText()#.strip(, ).split(, ) if self.listCtrlStatus.GetItem(2,0).GetText() == Event Selected: : SelRunList = self.listCtrlStatus.GetItem(1,1).GetText().strip(, ).split(, ) SelChanList = [] SelCycList = [] SelEventID = self.listCtrlStatus.GetItem(2,1).GetText()#.strip(, ).split(, ) else: if self.listCtrlStatus.GetItem(1,1).GetText() == All: SelRunList = [] for iRun in range(self.checkListRuns.GetItemCount()): SelRunList.append(str(self.checkListRuns.GetItemText(iRun))) else: SelRunList = self.listCtrlStatus.GetItem(1,1).GetText().strip(, ).split(, ) SelChanList = self.checkListBoxChans.GetCheckedStrings() if self.listCtrlStatus.GetItem(3,1).GetText() == All: SelCycList = [] else: SelCycList = self.listCtrlStatus.GetItem(3,1).GetText().strip(, ).split(, ) SelEventID = '' elif self.notebook.GetSelection() == 1: SelTestID = self.listCtrlStatus.GetItem(0,1).GetText()#.strip(, ).split(, ) SelRunList = self.listCtrlStatus.GetItem(1,1).GetText().strip(, ).split(, ) SelChanList = [] SelCycList = [] SelEventID = '' ##VTS.MsgBox(Test,eWO: + SelTestID + \nRuns: + str(SelRunList) + \nChans: + str(SelChanList) + \nCycles: + str(SelCycList) + \nEvent: + SelEventID) #cleanup to prevent memory leak if previously plotted plt.close('all') ##make sure all figure windows are closed fig = [] ax = [] #prep data for plotting plotting myeWO = str(SelTestID) nRuns = len(SelRunList) myRuns = [] for iRuns in range(nRuns): myRuns.append(str(SelRunList[iRuns])) nChans = len(SelChanList) myChans = [] for iChan in range(nChans): myChans.append(str(SelChanList[iChan])) dataLst = VTS.FetchSQLRunDataByName(myeWO, myRuns, myChans) lenData = len(dataLst) dataArry = np.zeros((lenData, nChans + 1)) for iPoint in range(lenData): dataArry[iPoint] = dataLst[iPoint] #begin plotting fig = plt.figure(1) ax = fig.add_subplot(111) myPlotLines = [] for iChan in range(nChans): tempLine, = ax.plot(dataArry[:,0], dataArry[:,iChan+1], label = myChans[iChan])
Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
Pribadi, Krishna wrote: Based on what I’ve been reading regarding MPL, it seems that the matplotlib show() function causes another instance of a GUI loop to remain suspended. right --don't use show(), in fact, don't use pylab for the most part: http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx and see the embedding_in_wx examples as well. I personally like wxMPL: http://agni.phys.iit.edu/~kmcivor/wxmpl/ -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
On Tue, Mar 9, 2010 at 2:23 PM, Chris Barker chris.bar...@noaa.gov wrote: Pribadi, Krishna wrote: Based on what I’ve been reading regarding MPL, it seems that the matplotlib show() function causes another instance of a GUI loop to remain suspended. right --don't use show(), in fact, don't use pylab for the most part: http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx and see the embedding_in_wx examples as well. I would agree with Chris that you should bite the bullet and embed it. That you are new to Python shouldn't be too much of a problem if you follow the recipe linked there. Note that the top links on that page are broken, but if you go to one of the last links: http://www.scipy.org/Matplotlib_figure_in_a_wx_panel ...this works. And if you need help getting it going, people can help you. Don't worry about all the fancy graphing stuff there, the draw method could have just been: def draw( self ): Draw data. if not hasattr( self, 'subplot' ): self.subplot = self.figure.add_subplot( 111 ) self.subplot.plot( [1,2,3]) and you could lose all the numpy geometry code and it would have been a boring plot but a simpler block of code. :D Che -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
On Tue, Mar 9, 2010 at 1:23 PM, Chris Barker chris.bar...@noaa.gov wrote: Pribadi, Krishna wrote: Based on what I’ve been reading regarding MPL, it seems that the matplotlib show() function causes another instance of a GUI loop to remain suspended. right --don't use show(), in fact, don't use pylab for the most part: http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx This page is badly out of date (half the links are broken) JDH -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
I know it's badly out of date... I'd like to embed it but I'm not quite sure where to begin... Do you think a simple solution like calling it from the system command line will open the plot in a new instance, so that the metadata GUI wont be hung up by the show()? I'd have to pass the selected metadata to a temporary file on disk. It's a bit of a dirty method... Thoughts? -Original Message- From: John Hunter [mailto:jdh2...@gmail.com] Sent: Tuesday, March 09, 2010 1:40 PM To: Chris Barker Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting On Tue, Mar 9, 2010 at 1:23 PM, Chris Barker chris.bar...@noaa.gov wrote: Pribadi, Krishna wrote: Based on what I've been reading regarding MPL, it seems that the matplotlib show() function causes another instance of a GUI loop to remain suspended. right --don't use show(), in fact, don't use pylab for the most part: http://www.scipy.org/Cookbook/Matplotlib/EmbeddingInWx This page is badly out of date (half the links are broken) JDH -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users This communication (including any attachments) is for the use of the intended recipient(s) only and may contain information that is confidential, privileged or otherwise legally protected. Any unauthorized use or dissemination of this communication is prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] embedding a plot function in existing wxapp GUI, problem replotting
On Tue, Mar 9, 2010 at 1:49 PM, Pribadi, Krishna krishna.prib...@harley-davidson.com wrote: I know it's badly out of date... I'd like to embed it but I'm not quite sure where to begin... Do you think a simple solution like calling it from the system command line will open the plot in a new instance, so that the metadata GUI wont be hung up by the show()? I'd have to pass the selected metadata to a temporary file on disk. It's a bit of a dirty method... Thoughts? I suggest following the embedding_is_wx*.py examples at http://matplotlib.sourceforge.net/examples/user_interfaces/index.html No use of pyplot or show in any of them. JDH -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users