Description
Bug report
Bug summary
On plots with the wxagg backend, when using zoom tool the zoom box (rubberband) doesn't display properly if there are multiple subfigures. It always displays on the last subfigure, regardless of which you click and drag on. The appropriate figure still zooms, regardless of where the box is drawn.
Code for reproduction
import wx
import matplotlib as mpl
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
class PlotFrame(wx.Frame):
def __init__(self, parent, title, *args, **kwargs):
wx.Frame.__init__(self, parent, title=title, *args, **kwargs)
self.fig = mpl.figure.Figure((5,4))
self.subplot1 = self.fig.add_subplot(211)
self.subplot2 = self.fig.add_subplot(212)
self.canvas = FigureCanvasWxAgg(self, wx.ID_ANY, self.fig)
self.subplot1.plot([0,100],[0,100])
self.subplot2.plot([0,100],[0,100])
self.toolbar = NavigationToolbar2WxAgg(self.canvas)
self.toolbar.Realize()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
sizer.Add(self.toolbar, 0, wx.GROW)
self.SetSizer(sizer)
self.Layout()
self.Fit()
self.CenterOnScreen()
self.Show(True)
if __name__ == '__main__':
app = wx.App(False)
frame = PlotFrame(None, 'My Plot Frame')
app.MainLoop()
Actual outcome
When using the zoom tool from the toolbar, if you click and drag on the top plot, the rubberband appears on the bottom plot. The upper plot is still the one that zooms, it is just the rubberband that is wrong. If you click and drag on the bottom plot, the rubberband appears on the bottom plot. This should be easy to verify with the code, but impossible to get a screenshot of :)
Expected outcome
When using the zoom tool from the toolbar, if you click and drag on the top plot, the rubberband appears on the top plot. If you click and drag on the bottom plot, the rubberband appears on the bottom plot.
Matplotlib version
- Operating System: macOS
- Matplotlib Version: 2.0.2
- Python Version: 2.7.12
- wx Version: 3.0.0.0
matplotlib and wx were installed using conda, default channel.