Python and Interactive Zoom Plot with Matplotlib

≡放荡痞女 提交于 2019-12-23 03:53:06

问题


I am using a Matplotlib plot (with Basemap) inside of a wxPython pane. I have got the plot (US map with scatter plot of cities). I am trying to do some interactive zoom capabilities (select a box on the map and "zoom" into that area only).

I have managed to get the toolbar to show, but when i click on the buttons, nothing happens. Seems like the toolbar is just there for show. Any Thoughts? Here is my code:

        # Set up area for plotting Basemap Plot and scatter plot
        self.figure = Figure(None,dpi=75)
        self.canvas = FigureCanvas(self.PlotPanel, -1, self.figure)
        self.axes = self.figure.add_axes([0,0,1,1],frameon=False)
        self.SetColor( (255,255,255) )

        # Toolbar Set up
        self.toolbar=NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        tw,th = self.toolbar.GetSizeTuple()
        fw,fh = self.canvas.GetSizeTuple()
        self.toolbar.SetSize(wx.Size(fw,th))
        sizer_7.Add(self.toolbar,0)
        self.toolbar.update()

回答1:


Have a look at the embedding_in_wx2 example, which works fine for me.

Maybe there is something wrong with your imports: you first have to import matplotlib, than set the backend (matplotlib.use('WXagg')) and then import the backend.

However it isn't easy to help you without having a full example with all imports.



来源:https://stackoverflow.com/questions/11192991/python-and-interactive-zoom-plot-with-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!