<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">After setting scale to <code class="notranslate">'log'</code> the default limits can cut off datapoints depending on the order of plotting.</p>
<p dir="auto">Note: calling <code class="notranslate">set_xscale</code>/<code class="notranslate">set_yscale</code> before calling <code class="notranslate">scatter</code> does not reproduce this bug.</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

# smallest span
x1 = np.array([1, 10])
y1 = np.array([10, 1])

# largest span
x2 = np.array([0.1, 100])
y2 = np.array([100, 0.1])

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(8,8))

ax1.scatter(x1, y1)
ax1.scatter(x2, y2)
ax1.set_title('linear; smallest span first', color='g')

ax2.scatter(x1, y1)
ax2.scatter(x2, y2)
ax2.set_xscale('log')
ax2.set_yscale('log')
ax2.set_title('log; smallest span first', color='r')

ax3.scatter(x2, y2)
ax3.scatter(x1, y1)
ax3.set_title('linear; largest span first', color='g')

ax4.scatter(x2, y2)
ax4.scatter(x1, y1)
ax4.set_xscale('log')
ax4.set_yscale('log')
ax4.set_title('log; largest span first', color='g')"><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-c"># smallest span</span>
<span class="pl-s1">x1</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">10</span>])
<span class="pl-s1">y1</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">10</span>, <span class="pl-c1">1</span>])

<span class="pl-c"># largest span</span>
<span class="pl-s1">x2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">0.1</span>, <span class="pl-c1">100</span>])
<span class="pl-s1">y2</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">100</span>, <span class="pl-c1">0.1</span>])

<span class="pl-s1">fig</span>, ((<span class="pl-s1">ax1</span>, <span class="pl-s1">ax2</span>), (<span class="pl-s1">ax3</span>, <span class="pl-s1">ax4</span>)) <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">2</span>,<span class="pl-c1">2</span>, <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">8</span>,<span class="pl-c1">8</span>))

<span class="pl-s1">ax1</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">y1</span>)
<span class="pl-s1">ax1</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x2</span>, <span class="pl-s1">y2</span>)
<span class="pl-s1">ax1</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'linear; smallest span first'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'g'</span>)

<span class="pl-s1">ax2</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">y1</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x2</span>, <span class="pl-s1">y2</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">set_xscale</span>(<span class="pl-s">'log'</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">set_yscale</span>(<span class="pl-s">'log'</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'log; smallest span first'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'r'</span>)

<span class="pl-s1">ax3</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x2</span>, <span class="pl-s1">y2</span>)
<span class="pl-s1">ax3</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">y1</span>)
<span class="pl-s1">ax3</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'linear; largest span first'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'g'</span>)

<span class="pl-s1">ax4</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x2</span>, <span class="pl-s1">y2</span>)
<span class="pl-s1">ax4</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">y1</span>)
<span class="pl-s1">ax4</span>.<span class="pl-en">set_xscale</span>(<span class="pl-s">'log'</span>)
<span class="pl-s1">ax4</span>.<span class="pl-en">set_yscale</span>(<span class="pl-s">'log'</span>)
<span class="pl-s1">ax4</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'log; largest span first'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'g'</span>)</pre></div>
<p dir="auto"><strong>Outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16648303/39756261-2053c188-52c9-11e8-9853-ab51e7ee99f8.png"><img src="https://user-images.githubusercontent.com/16648303/39756261-2053c188-52c9-11e8-9853-ab51e7ee99f8.png" alt="log-order-bug" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Matplotlib version: <code class="notranslate">2.2.2</code></li>
<li>Matplotlib backend: <code class="notranslate">MacOSX</code></li>
<li>Python version: <code class="notranslate">2.7.14</code> and <code class="notranslate">3.6.4</code></li>
</ul>
<p dir="auto">As mentioned <a href="http://stackoverflow.com/q/38800189/3904031" rel="nofollow">in this SE question</a> a scatter plot is not autoscaling to include all of the data if <code class="notranslate">plt.yscale('log')</code> is used after <code class="notranslate">plt.scatter()</code>. This happens for the y-axis but not the x-axis in the example, and does not happen for <code class="notranslate">plt.plot()</code>.</p>
<p dir="auto">In an <a href="http://stackoverflow.com/a/18774741/3904031" rel="nofollow">earlier answer</a> by a developer, <code class="notranslate">ax.set_yscale('log')</code> is shown following <code class="notranslate">ax.scatter()</code>, so I am wondering if this may be a bug.</p>
<p dir="auto">Using matplotlib version 1.5.1 and python 2.7.11</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/17236804/17460373/045f64e4-5c96-11e6-8477-9702baec4939.png"><img src="https://cloud.githubusercontent.com/assets/17236804/17460373/045f64e4-5c96-11e6-8477-9702baec4939.png" alt="image" style="max-width: 100%;"></a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt

X = [0.997, 2.643, 0.354, 0.075, 1.0, 0.03, 2.39, 0.364, 0.221, 0.437]
Y = [15.487507, 2.320735, 0.085742, 0.303032, 1.0, 0.025435, 4.436435,
     0.025435, 0.000503, 2.320735]

plt.figure()

plt.subplot(2,2,1)
plt.scatter(X, Y)
plt.xscale('log')
plt.yscale('log')
plt.title('scatter - scale last')   

plt.subplot(2,2,2)
plt.plot(X, Y)
plt.xscale('log')
plt.yscale('log')
plt.title('plot - scale last')   

plt.subplot(2,2,3)
plt.xscale('log')
plt.yscale('log')
plt.scatter(X, Y)
plt.title('scatter - scale first')   

plt.subplot(2,2,4)
plt.xscale('log')
plt.yscale('log')
plt.plot(X, Y)
plt.title('plot - scale first')   

plt.show()"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt

X = [0.997, 2.643, 0.354, 0.075, 1.0, 0.03, 2.39, 0.364, 0.221, 0.437]
Y = [15.487507, 2.320735, 0.085742, 0.303032, 1.0, 0.025435, 4.436435,
     0.025435, 0.000503, 2.320735]

plt.figure()

plt.subplot(2,2,1)
plt.scatter(X, Y)
plt.xscale('log')
plt.yscale('log')
plt.title('scatter - scale last')   

plt.subplot(2,2,2)
plt.plot(X, Y)
plt.xscale('log')
plt.yscale('log')
plt.title('plot - scale last')   

plt.subplot(2,2,3)
plt.xscale('log')
plt.yscale('log')
plt.scatter(X, Y)
plt.title('scatter - scale first')   

plt.subplot(2,2,4)
plt.xscale('log')
plt.yscale('log')
plt.plot(X, Y)
plt.title('plot - scale first')   

plt.show()
</code></pre></div>