2

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 Answer 1

1
+50

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This worked! I think it had to do with imports AND placement of the functions. The example was fantastic -- don't know how i missed it. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.