SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Jeremy O'D. <je...@o-...> - 2003年12月27日 13:18:17
Hi Eugene,
I've had a quick look into the problem for you, and I can't give an immediate 
solution, but I'll try to get a fix in the next few days.
I can say that in the original design, the intention was that show() would be 
the last line of any script. I know that John (author of virtually everything 
in Matplotlib except backend_wx) has recently made some changes to allow 
show() to be called more than once.
Unfortunately, the code needed to do thisis quite specific to each GUI 
library, and I cannot simply port what has been done for GTK (I've just tried 
something very close to the GTK implementation, and it doesn't work).
A few questions for John Hunter: 
I think I need to do something like the following:
- show() must now instantiate any figures already defined and enter the the 
main event loop. ShowOn needs to keep track of this.
- I need to keep track of the number of figures instantiated. I assume that 
Gcf.destroy() does this.
- I need to ensure that I do not exit when the last figure is destroyed, and 
therefore need to manage that I may need to create a new figure manager if 
there is none.
Have I missed anything?
Regards
Jeremy
Eugene A. Suchkov writes:
>
> Hi all!
> 
> There are some bug's I've found in two days I got started with echotag.
> 
> 1) I can't make 2 plots using WX-backend sequentially
> 
> For example:
> 
> ---CODE---
> 
> import matplotlib
> matplotlib.use('WX')
> from matplotlib.matlab import *
> plot([1,2,3,4])
> show()
> plot([1,4,9,16])
> show()
> 
> --END CODE--
> 
> Well, everything is OK, while building 1st graph, but then an error
> occurs:
> 
> --OUTPUT--
> 
> Traceback (most recent call last):
> File "plot.py", line 7, in ?
> plot([1,4,9,16])
> File "/usr/lib/python2.2/site-packages/matplotlib/matlab.py", line
> 723, in plot draw_if_interactive()
> File
> "/usr/lib/python2.2/site-packages/matplotlib/backends/backend_wx.py",
> line 986, in draw_if_interactive current_fig =
> Gcf().get_current_figwin().figure AttributeError: 'Gcf' object has no
> attribute 'get_current_figwin'
> 
> --END OUTPUT--
> It was tested on Linux and Windows. Versions 0.40 and 0.32
> 
> When I'm using GTK everything is OK with both graphs, but using WX is
> critical :(
From: Jeremy O'D. <je...@o-...> - 2003年12月28日 22:45:12
Hi Eugene,
On Sunday 28 December 2003 7:34 am, you wrote:
>
> I's really useful feature, e.g.:
>
> I have a WX program. It has some buttons, checkboxes, radiobuttons, to
> combine the options (detrending, plotting autocorrelation etc), and I
> can perform this options for any file with data. Now the user should
> quit this program to plot anothe graph... I's really tiring :(
Looking at this description, I wonder if it might be better for you to embed a 
figure in your application. You will then be able to build up the figure as 
you want it and hit the 'save' button, then maybe continue with changes, or 
clear the data in the chart.
The example 'embedding_in_wx.py' shows how to embed a Matplotlib chart in a 
wxFrame (and it works just as well if the PlotFigure class is derived from 
wxPanel, which is what you would probably do in a larger program than the 
short example).
The plotted data itself is stored in a FigureWx instance. This needs to be 
associated with a FigureManager and Toolbar instance if you want to be able 
to pan, zoom and save plot images.
In the example, the plotting is done in a single function, plot_data(). 
However, it is easy to add event handling functions which act on the Figure, 
e.g., if data is held in self.data_x and self.data_y, and the axis instance 
is self.axis:
(in __init__() for PlotFigure):
 EVT_BUTTON(self, ID_REGRESSION, self.onRegressionButton)
...
and new function:
def onRegressionButton(self, evt):
 reg_x, reg_y = PerformRegression(self.data_x, self.data_y)
 self.axis.plot(reg_x, reg_y)
 self.toolbar.update()
 self.fig.draw() 
Hope this helps. I'll make the changes for show() anyway - it is important to 
John and I that all backends are as close to identical as possible, and you 
have clearly identified the bug for me. Good luck, and thanks for the 
feedback.
Regards
Jeremy
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /