<p dir="auto">Ok this is an odd one:</p>
<p dir="auto">If you have a matplotlib figure with multiple subplots and try to plot a regplot inside one of the the axes, regplot will update the axes limits of the last axes of the subplot.</p>
<p dir="auto">The cause for this is pretty simple. in <a href="https://github.com/mwaskom/seaborn/blob/29d1075cd56878ad2ba71f537df2cd73170ad847/seaborn/regression.py#L327">this line</a> the regplot function calls <code class="notranslate">plt.plot</code> instead of <code class="notranslate">ax.plot</code>. Hence the currently active axes (meaning the last subplot) is targeted by this line, automatically updating its limits.</p>
<p dir="auto">When using <code class="notranslate">regplot()</code> on a figure with multiple axes, the x and y limits on the last subplot are partially determined by data plotted in the other axes.</p>
<p dir="auto">For example, the following code will produce a figure where the range of x values is way too large on the second subplot:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import seaborn
import numpy as np
import pandas as pd

np.random.seed(32)
y = np.random.randn(20, 1)
x0 = np.random.randn(20, 1) + 100
x1 = np.random.randn(20, 1)

df = pd.DataFrame(np.hstack([y, x0, x1]), columns=['y', 'x0', 'x1'])

fig, axes = plt.subplots(1, 2)
seaborn.regplot(x='x0', y='y', data=df, ax=axes[0])
seaborn.regplot(x='x1', y='y', data=df, ax=axes[1])

plt.show();"><pre lang="import" class="notranslate"><code class="notranslate">import seaborn
import numpy as np
import pandas as pd

np.random.seed(32)
y = np.random.randn(20, 1)
x0 = np.random.randn(20, 1) + 100
x1 = np.random.randn(20, 1)

df = pd.DataFrame(np.hstack([y, x0, x1]), columns=['y', 'x0', 'x1'])

fig, axes = plt.subplots(1, 2)
seaborn.regplot(x='x0', y='y', data=df, ax=axes[0])
seaborn.regplot(x='x1', y='y', data=df, ax=axes[1])

plt.show();
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2933570/45769602-f87a9e80-bbf4-11e8-88fb-95a5ca88ea8f.png"><img src="https://user-images.githubusercontent.com/2933570/45769602-f87a9e80-bbf4-11e8-88fb-95a5ca88ea8f.png" alt="regplot" style="max-width: 100%;"></a></p>
<p dir="auto">The reason seems to be that the <code class="notranslate">plot()</code> function in <code class="notranslate">_RegressionPlotter</code> uses <code class="notranslate">plt.plot()</code> to create (and then remove) a line, in order to determine what colour to use for the regplot (line 327 of regression.py).</p>
<p dir="auto"><code class="notranslate">lines, = plt.plot(self.x.mean(), self.y.mean())</code></p>
<p dir="auto">This has the unintended side effect of updating the limits of one of the plots. Because this is done with <code class="notranslate">plt</code> instead of <code class="notranslate">ax</code>, this affects the last of the subplots created using <code class="notranslate">subplots()</code>, rather than the ax that has been passed to regplot. In the example above, because the first and second columns of X have very different means, the xlim of the second plot is pulled very far to the right.</p>
<p dir="auto">I believe this can be fixed by changing <code class="notranslate">plt.plot()</code> on line 327 of regression.py to <code class="notranslate">ax.plot()</code>, and will submit a PR. The proposed change will also cause all subplots to be plotted in the same colour by default (unlike above). However, this will also be more consistent with <code class="notranslate">lmplot</code>.</p>
<p dir="auto">Version info:<br>
python: 3.6.1<br>
seaborn: 0.9.0<br>
matplotlib: 2.0.2</p>