简体   繁体   English

Matplotlib与wxPython ScrolledWindow一起缩放工作

[英]Matplotlib zooming work in conjunction with wxPython ScrolledWindow

I've got a Matplotlib canvas (FigureCanvasWxAgg) that I'm displaying inside of a wx.ScrolledWindow. 我有一个Matplotlib画布(FigureCanvasWxAgg),我在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). 问题是我希望Matplotlib的默认缩放和平移功能与ScrolledWindow一起使用,这样当用户在画布中缩放图像时,ScrolledWindow应该变大以适应缩放(滚动条变为小)。 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. 类似地,对于平移,我希望默认的matplotlib平移工具与我们的ScrolledWindow一起使用,这样当用户在画布上平移图像时,ScrolledWindow的滚动条应该相应地移动。

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. 感谢您提供任何帮助/提示。

The problem is that the default Zoom and Pan don't resize the figure, they just change the limits and redraw the plot. 问题是默认的ZoomPan不会调整图形大小,它们只是更改限制并重绘图形。

What you want is the Zoom to resize (keeping the same limits) and the Pan to work as in a normal Scrolled window. 你想要的是Zoom调整大小(保持相同的限制)和Pan工作,就像在普通的滚动窗口中一样。 I have never tried this, fig.set_size_inches(w,h) should do the trick. 我从未尝试过这个, fig.set_size_inches(w,h)应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM