<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">When using the “WXAgg” backend, I’m unable to draw a zoom region on one of the two axes of a matplotlib figure.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# coding=utf-8

import matplotlib

matplotlib.use(&quot;WXAgg&quot;)

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, &quot;…&quot;, 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__ == &quot;__main__&quot;:
    app = App(0)

    app.MainLoop()"><pre class="notranslate"><span class="pl-c"># coding=utf-8</span>

<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>

<span class="pl-s1">matplotlib</span>.<span class="pl-en">use</span>(<span class="pl-s">"WXAgg"</span>)

<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wx</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">figure</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span>
<span class="pl-k">import</span> <span class="pl-s1">skimage</span>.<span class="pl-s1">data</span>
<span class="pl-k">import</span> <span class="pl-s1">wx</span>


<span class="pl-k">class</span> <span class="pl-v">App</span>(<span class="pl-s1">wx</span>.<span class="pl-v">App</span>):
    <span class="pl-k">def</span> <span class="pl-v">OnInit</span>(<span class="pl-s1">self</span>):
        <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">skimage</span>.<span class="pl-s1">data</span>.<span class="pl-en">chelsea</span>()
        <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">skimage</span>.<span class="pl-s1">data</span>.<span class="pl-en">chelsea</span>()

        <span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-v">Frame</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>)

        <span class="pl-s1">frame</span>.<span class="pl-v">Show</span>(<span class="pl-c1">True</span>)

        <span class="pl-k">return</span> <span class="pl-c1">True</span>


<span class="pl-k">class</span> <span class="pl-v">Frame</span>(<span class="pl-s1">wx</span>.<span class="pl-v">Frame</span>):
    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">x</span>, <span class="pl-s1">y</span>):
        <span class="pl-s1">wx</span>.<span class="pl-v">Frame</span>.<span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-c1">None</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-s">"…"</span>, <span class="pl-s1">size</span><span class="pl-c1">=</span>(<span class="pl-c1">800</span>, <span class="pl-c1">600</span>))

        <span class="pl-s1">self</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span>
        <span class="pl-s1">self</span>.<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">y</span>

        <span class="pl-s1">self</span>.<span class="pl-s1">figure</span>, (<span class="pl-s1">a</span>, <span class="pl-s1">b</span>) <span class="pl-c1">=</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span>.<span class="pl-en">subplots</span>(
            <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">12</span>, <span class="pl-c1">6</span>),
            <span class="pl-s1">ncols</span><span class="pl-c1">=</span><span class="pl-c1">2</span>,
            <span class="pl-s1">sharex</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,
            <span class="pl-s1">sharey</span><span class="pl-c1">=</span><span class="pl-c1">True</span>
        )

        <span class="pl-s1">a</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">self</span>.<span class="pl-s1">x</span>)
        <span class="pl-s1">b</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">self</span>.<span class="pl-s1">y</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">canvas</span> <span class="pl-c1">=</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span>.<span class="pl-v">FigureCanvasWxAgg</span>(<span class="pl-s1">self</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-s1">self</span>.<span class="pl-s1">figure</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">sizer</span> <span class="pl-c1">=</span> <span class="pl-s1">wx</span>.<span class="pl-v">BoxSizer</span>(<span class="pl-s1">wx</span>.<span class="pl-v">VERTICAL</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span> <span class="pl-c1">=</span> <span class="pl-v">NavigationToolbar</span>(<span class="pl-s1">self</span>.<span class="pl-s1">canvas</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span>.<span class="pl-v">Realize</span>()

        <span class="pl-s1">self</span>.<span class="pl-s1">sizer</span>.<span class="pl-v">Add</span>(<span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span>, <span class="pl-c1">0</span>, <span class="pl-s1">wx</span>.<span class="pl-v">GROW</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span>.<span class="pl-en">update</span>()

        <span class="pl-s1">self</span>.<span class="pl-s1">sizer</span>.<span class="pl-v">Add</span>(<span class="pl-s1">self</span>.<span class="pl-s1">canvas</span>, <span class="pl-c1">1</span>, <span class="pl-s1">wx</span>.<span class="pl-v">LEFT</span> <span class="pl-c1">|</span> <span class="pl-s1">wx</span>.<span class="pl-v">TOP</span> <span class="pl-c1">|</span> <span class="pl-s1">wx</span>.<span class="pl-v">GROW</span>)

        <span class="pl-s1">self</span>.<span class="pl-v">SetSizer</span>(<span class="pl-s1">self</span>.<span class="pl-s1">sizer</span>)

        <span class="pl-s1">self</span>.<span class="pl-v">Fit</span>()

    <span class="pl-k">def</span> <span class="pl-v">OnPaint</span>(<span class="pl-s1">self</span>, <span class="pl-s1">event</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">canvas</span>.<span class="pl-en">draw</span>()


<span class="pl-k">class</span> <span class="pl-v">NavigationToolbar</span>(<span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span>.<span class="pl-v">NavigationToolbar2WxAgg</span>):
    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">canvas</span>):
        <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span>.<span class="pl-v">NavigationToolbar2WxAgg</span>.<span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">canvas</span>)


<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span> <span class="pl-s">"__main__"</span>:
    <span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">App</span>(<span class="pl-c1">0</span>)

    <span class="pl-s1">app</span>.<span class="pl-v">MainLoop</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/315821/29936010-ae848284-8e4e-11e7-8f91-6f61fc8f26bb.png"><img width="1192" alt="bug" src="https://user-images.githubusercontent.com/315821/29936010-ae848284-8e4e-11e7-8f91-6f61fc8f26bb.png" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">The Jupyter backend, for example, works:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="%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()"><pre class="notranslate"><span class="pl-c1">%</span><span class="pl-s1">matplotlib</span> <span class="pl-s1">notebook</span>

<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span>
<span class="pl-k">import</span> <span class="pl-s1">skimage</span>.<span class="pl-s1">data</span>

<span class="pl-s1">figure</span>, (<span class="pl-s1">a</span>, <span class="pl-s1">b</span>) <span class="pl-c1">=</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span>.<span class="pl-en">subplots</span>(
    <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">6</span>, <span class="pl-c1">3</span>),
    <span class="pl-s1">ncols</span><span class="pl-c1">=</span><span class="pl-c1">2</span>,
    <span class="pl-s1">sharex</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,
    <span class="pl-s1">sharey</span><span class="pl-c1">=</span><span class="pl-c1">True</span>
)

<span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-s1">skimage</span>.<span class="pl-s1">data</span>.<span class="pl-en">chelsea</span>()

<span class="pl-s1">a</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">image</span>)
<span class="pl-s1">b</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">image</span>)

<span class="pl-s1">figure</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating System: macOS 10.11.6</li>
<li>Matplotlib Version: 2.0.2</li>
<li>Python Version: 2.7.13</li>
<li>Jupyter Version (if applicable):</li>
<li>Other Libraries:</li>
</ul>


<p dir="auto">cc: <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/RobinD42/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/RobinD42">@RobinD42</a></p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
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.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="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()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">wx</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">as</span> <span class="pl-s1">mpl</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span> <span class="pl-k">import</span> <span class="pl-v">NavigationToolbar2WxAgg</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">backends</span>.<span class="pl-s1">backend_wxagg</span> <span class="pl-k">import</span> <span class="pl-v">FigureCanvasWxAgg</span>

<span class="pl-k">class</span> <span class="pl-v">PlotFrame</span>(<span class="pl-s1">wx</span>.<span class="pl-v">Frame</span>):
    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">parent</span>, <span class="pl-s1">title</span>, <span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>):
        <span class="pl-s1">wx</span>.<span class="pl-v">Frame</span>.<span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">parent</span>, <span class="pl-s1">title</span><span class="pl-c1">=</span><span class="pl-s1">title</span>, <span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">mpl</span>.<span class="pl-s1">figure</span>.<span class="pl-v">Figure</span>((<span class="pl-c1">5</span>,<span class="pl-c1">4</span>))
        <span class="pl-s1">self</span>.<span class="pl-s1">subplot1</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-c1">211</span>)
        <span class="pl-s1">self</span>.<span class="pl-s1">subplot2</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-c1">212</span>)
        <span class="pl-s1">self</span>.<span class="pl-s1">canvas</span> <span class="pl-c1">=</span> <span class="pl-v">FigureCanvasWxAgg</span>(<span class="pl-s1">self</span>, <span class="pl-s1">wx</span>.<span class="pl-v">ID_ANY</span>, <span class="pl-s1">self</span>.<span class="pl-s1">fig</span>)

        <span class="pl-s1">self</span>.<span class="pl-s1">subplot1</span>.<span class="pl-en">plot</span>([<span class="pl-c1">0</span>,<span class="pl-c1">100</span>],[<span class="pl-c1">0</span>,<span class="pl-c1">100</span>])
        <span class="pl-s1">self</span>.<span class="pl-s1">subplot2</span>.<span class="pl-en">plot</span>([<span class="pl-c1">0</span>,<span class="pl-c1">100</span>],[<span class="pl-c1">0</span>,<span class="pl-c1">100</span>])

        <span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span> <span class="pl-c1">=</span> <span class="pl-v">NavigationToolbar2WxAgg</span>(<span class="pl-s1">self</span>.<span class="pl-s1">canvas</span>)
        <span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span>.<span class="pl-v">Realize</span>()

        <span class="pl-s1">sizer</span> <span class="pl-c1">=</span> <span class="pl-s1">wx</span>.<span class="pl-v">BoxSizer</span>(<span class="pl-s1">wx</span>.<span class="pl-v">VERTICAL</span>)
        <span class="pl-s1">sizer</span>.<span class="pl-v">Add</span>(<span class="pl-s1">self</span>.<span class="pl-s1">canvas</span>, <span class="pl-c1">1</span>, <span class="pl-s1">wx</span>.<span class="pl-v">LEFT</span> <span class="pl-c1">|</span> <span class="pl-s1">wx</span>.<span class="pl-v">TOP</span> <span class="pl-c1">|</span> <span class="pl-s1">wx</span>.<span class="pl-v">GROW</span>)
        <span class="pl-s1">sizer</span>.<span class="pl-v">Add</span>(<span class="pl-s1">self</span>.<span class="pl-s1">toolbar</span>, <span class="pl-c1">0</span>, <span class="pl-s1">wx</span>.<span class="pl-v">GROW</span>)

        <span class="pl-s1">self</span>.<span class="pl-v">SetSizer</span>(<span class="pl-s1">sizer</span>)
        <span class="pl-s1">self</span>.<span class="pl-v">Layout</span>()
        <span class="pl-s1">self</span>.<span class="pl-v">Fit</span>()
        <span class="pl-s1">self</span>.<span class="pl-v">CenterOnScreen</span>()
        <span class="pl-s1">self</span>.<span class="pl-v">Show</span>(<span class="pl-c1">True</span>)

<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span> <span class="pl-s">'__main__'</span>:
    <span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-s1">wx</span>.<span class="pl-v">App</span>(<span class="pl-c1">False</span>)
    <span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-v">PlotFrame</span>(<span class="pl-c1">None</span>, <span class="pl-s">'My Plot Frame'</span>)
    <span class="pl-s1">app</span>.<span class="pl-v">MainLoop</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
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 :)</p>
<p dir="auto"><strong>Expected outcome</strong><br>
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.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating System: macOS</li>
<li>Matplotlib Version: 2.0.2</li>
<li>Python Version: 2.7.12</li>
<li>wx Version: 3.0.0.0</li>
</ul>
<p dir="auto">matplotlib and wx were installed using conda, default channel.</p>