Python and Interactive Zoom Plot with Matplotlib

2019-06-06 12:17发布

问题:

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()