Working with Matplotlib scaling in conjunction with wxPython ScrolledWindow

I have a Matplotlib canvas (FigureCanvasWxAgg), which I show inside wx.ScrolledWindow. The problem is that I would like to have the default zoom and pan functions of Matplotlib in combination with ScrolledWindow, so when the user zooms in on the canvas, ScrolledWindow needs to become larger in order to adapt to scaling (scrollbars become smaller). Similarly, for panning, I would like the matplotlib default panning tool to work with our ScrolledWindow, so that when the user clicks on the canvas, the ScrolledWindow scrollbars should move accordingly.

I searched for a while and did not see anyone even mentioning, if possible. Can someone point me in the right direction?

Thanks for the help / advice.

+4
source share
1 answer

The problem is that the default values โ€‹โ€‹of Zoom and Pan do not change the size of the figure, they just change the limits and redraw the graph.

You want Zoom resize (keeping the same limits), and Pan work as in a normal scrolled window. I have never tried this, fig.set_size_inches(w,h) should do the trick.

0
source

All Articles