<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
In OSX using a Jupyter notebook with Matplotlib 2.0.2 and inline display, subplots apparently render after all the code in a cell has executed. The result is that if an object changes between one subplot plot call and the next, only the newest object is shown in both subplots.</p>
<p dir="auto"><strong>This is fixed in 2.0.2, but I'm posting this issue for folks that might run into this.</strong></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 numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

A = np.array([[1,2,3],[4,5,6],[7,8,9]])
B = A.copy()
fig, axes = plt.subplots(1,3)
ax0, ax1, ax2 = axes
ax0.matshow(A)
A[0,0] = 9
ax1.matshow(B)
ax2.matshow(A)
# Expected behavior - first and second subplots are the same.
# Observed behavior - first and third subplots are the same.
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-c1">%</span><span class="pl-s1">matplotlib</span> <span class="pl-s1">inline</span>

<span class="pl-v">A</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([[<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>],[<span class="pl-c1">4</span>,<span class="pl-c1">5</span>,<span class="pl-c1">6</span>],[<span class="pl-c1">7</span>,<span class="pl-c1">8</span>,<span class="pl-c1">9</span>]])
<span class="pl-v">B</span> <span class="pl-c1">=</span> <span class="pl-v">A</span>.<span class="pl-en">copy</span>()
<span class="pl-s1">fig</span>, <span class="pl-s1">axes</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">1</span>,<span class="pl-c1">3</span>)
<span class="pl-s1">ax0</span>, <span class="pl-s1">ax1</span>, <span class="pl-s1">ax2</span> <span class="pl-c1">=</span> <span class="pl-s1">axes</span>
<span class="pl-s1">ax0</span>.<span class="pl-en">matshow</span>(<span class="pl-v">A</span>)
<span class="pl-v">A</span>[<span class="pl-c1">0</span>,<span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-c1">9</span>
<span class="pl-s1">ax1</span>.<span class="pl-en">matshow</span>(<span class="pl-v">B</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">matshow</span>(<span class="pl-v">A</span>)
<span class="pl-c"># Expected behavior - first and second subplots are the same.</span>
<span class="pl-c"># Observed behavior - first and third subplots are the same.</span></pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1432092/29904415-5a4dbcb0-8dce-11e7-8668-88f73a586fe0.png"><img src="https://user-images.githubusercontent.com/1432092/29904415-5a4dbcb0-8dce-11e7-8668-88f73a586fe0.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong><br>
I would expect the first and second subplots to be the same.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating System: OSX 10.10.5</li>
<li>Matplotlib Version: 1.5.1</li>
<li>Python Version: 3.5.2</li>
<li>Jupyter Version (if applicable): 5.0.0</li>
<li>Other Libraries:</li>
</ul>
<p dir="auto">Installed from Anaconda 4.3.</p>
<p dir="auto">The following code produces a horizontal gradient plot instead of a horizontal line:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm

Z=np.zeros((100,100))
Z[50]=100
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
ax.imshow(Z,cmap=matplotlib.cm.Greys)
Z[...]= np.arange(100.)[np.newaxis,:]

plt.show() "><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">cm</span>

<span class="pl-v">Z</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">zeros</span>((<span class="pl-c1">100</span>,<span class="pl-c1">100</span>))
<span class="pl-v">Z</span>[<span class="pl-c1">50</span>]<span class="pl-c1">=</span><span class="pl-c1">100</span>
<span class="pl-s1">fig</span><span class="pl-c1">=</span><span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">imshow</span>(<span class="pl-v">Z</span>,<span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s1">matplotlib</span>.<span class="pl-s1">cm</span>.<span class="pl-v">Greys</span>)
<span class="pl-v">Z</span>[...]<span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">100.</span>)[<span class="pl-s1">np</span>.<span class="pl-s1">newaxis</span>,:]

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>() </pre></div>
<p dir="auto">Please note that if we comment <code class="notranslate">Z[50]=100</code> the issue is not apparent as an all white figure is created as expected, but e.g. in Qt4Agg backend, mouseover values shows the altered Z values.</p>
<p dir="auto">This means that imshow does not copy the data array but sets the color scale at the <code class="notranslate">ax.imshow()</code> call.</p>
<p dir="auto">If data is intentionally not copied, I'd suggest adding a big warning about this behavior in the documentation and then the colorscale determination should be deferred until the figure is actually drawn. Otherwise the data should be copied.</p>
<ul dir="auto">
<li>pip installed Matplotlib: 1.5.0, numpy: 1.10.1</li>
<li>Ubuntu 14.04 python: 3.4.3</li>
</ul>