Troubles with WX backend

Hi Eugene,

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 :frowning:

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

···

On Sunday 28 December 2003 7:34 am, you wrote: