Issue 1:
Bug report

Bug summary

When using the “WXAgg” backend, I’m unable to draw a zoom region on one of the two axes of a matplotlib figure.

Code for reproduction

# coding=utf-8

import matplotlib

matplotlib.use("WXAgg")

import matplotlib.backends.backend_wx
import matplotlib.backends.backend_wxagg
import matplotlib.figure
import matplotlib.pyplot
import skimage.data
import wx

class App(wx.App):
def OnInit(self):
x = skimage.data.chelsea()
y = skimage.data.chelsea()

frame = Frame(x, y)

frame.Show(True)

return True

class Frame(wx.Frame):
def __init__(self, x, y):
wx.Frame.__init__(self, None, -1, "…", size=(800, 600))

self.x = x
self.y = y

self.figure, (a, b) = matplotlib.pyplot.subplots(
figsize=(12, 6),
ncols=2,
sharex=True,
sharey=True
)

a.imshow(self.x)
b.imshow(self.y)

self.canvas = matplotlib.backends.backend_wxagg.FigureCanvasWxAgg(self, -1, self.figure)

self.sizer = wx.BoxSizer(wx.VERTICAL)

self.toolbar = NavigationToolbar(self.canvas)

self.toolbar.Realize()

self.sizer.Add(self.toolbar, 0, wx.GROW)

self.toolbar.update()

self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)

self.SetSizer(self.sizer)

self.Fit()

def OnPaint(self, event):
self.canvas.draw()

class NavigationToolbar(matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg):
def __init__(self, canvas):
matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg.__init__(self, canvas)

if __name__ == "__main__":
app = App(0)

app.MainLoop()

Actual outcome

Expected outcome

The Jupyter backend, for example, works:

%matplotlib notebook

import matplotlib.pyplot
import skimage.data

figure, (a, b) = matplotlib.pyplot.subplots(
figsize=(6, 3),
ncols=2,
sharex=True,
sharey=True
)

image = skimage.data.chelsea()

a.imshow(image)
b.imshow(image)

figure.show()

Matplotlib version

Operating System: macOS 10.11.6

Matplotlib Version: 2.0.2

Python Version: 2.7.13

Jupyter Version (if applicable):

Other Libraries:

cc: @RobinD42

Issue 2:
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.