4

I've got a Matplotlib canvas (FigureCanvasWxAgg) that I'm displaying inside of a wx.ScrolledWindow. The problem is that I'd like to have the default zooming and panning functionality of Matplotlib work in conjunction with the ScrolledWindow, so that when the user zooms the image within the canvas, the ScrolledWindow should become larger to accommodate for the zooming (scrollbars become smaller). Similarly for panning, I'd like the default matplotlib panning tool to work in conjunction with our ScrolledWindow, so that when the user pans the image on the canvas, the ScrolledWindow's scrollbars should move accordingly.

I've been searching for a while now and have not seen anyone even mention if this is possible. Could anyone point me in the right direction?

Thank you for any help/tips.

adchilds
  • 963
  • 2
  • 9
  • 22
  • were you able to figure this out? I am looking for embedding interactive figures into wxpython as well. – Joshua Aug 01 '12 at 16:46
  • I wasn't, no. Sorry. I implemented my own zooming and panning functionality. – adchilds Aug 01 '12 at 18:21
  • @adchilds: If you are able, you could provide your solution here as an answer to benefit others. – pelson Aug 11 '12 at 12:00
  • I tried something similar and had no luck. But I found that MPL seems to have better support for Qt4 backend. So If you do matplotlib.use('Qt4Agg') right after importing matplotlib, and let pyplot spawn a window. Then it has all the default functions like zooming and panning etc. So, I mixed this into my wxpython app... – otterb May 25 '14 at 11:10

1 Answers1

0

The problem is that the default Zoom and Pan don't resize the figure, they just change the limits and redraw the plot.

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

fariza
  • 634
  • 1
  • 5
  • 19