Question

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()
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top