<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Plotting negative values on a log scale is possible. However it changes the axis limits in a seemingly arbitrary way.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<p dir="auto">The following shows three scatter plots. The <code class="notranslate">x</code> values<br>
(1) are all positive<br>
(2) contain one negative value<br>
(3) have the negative value filtered out</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np; np.random.seed(1)
import matplotlib.pyplot as plt

x = np.random.rayleigh(100,400)
y = np.random.rand(len(x))

fig, (ax,ax2, ax3) = plt.subplots(nrows=3)

ax.scatter(x,y)
ax.set_xscale(&quot;log&quot;)
ax.set_title(&quot;Scatter of all-positive values&quot;)

ax2.scatter(x-2,y)
ax2.set_xscale(&quot;log&quot;)
ax2.set_title(&quot;Scatter with one negative value&quot;)

cond = x-2 &gt; 0
ax3.scatter((x-2)[cond],y[cond])
ax3.set_xscale(&quot;log&quot;)
ax3.set_title(&quot;Expected scatter with one negative value&quot;)

plt.tight_layout()
plt.show()"><pre class="notranslate"><code class="notranslate">import numpy as np; np.random.seed(1)
import matplotlib.pyplot as plt

x = np.random.rayleigh(100,400)
y = np.random.rand(len(x))

fig, (ax,ax2, ax3) = plt.subplots(nrows=3)

ax.scatter(x,y)
ax.set_xscale("log")
ax.set_title("Scatter of all-positive values")

ax2.scatter(x-2,y)
ax2.set_xscale("log")
ax2.set_title("Scatter with one negative value")

cond = x-2 &gt; 0
ax3.scatter((x-2)[cond],y[cond])
ax3.set_xscale("log")
ax3.set_title("Expected scatter with one negative value")

plt.tight_layout()
plt.show()
</code></pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">The second subplot, where the data contains a negative value, shows only part of the valid data, because the axis is autoscaled to some seemingly arbitrary region.</p>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/23121882/37407656-7a2ba57c-279a-11e8-8957-1f85be04d97e.png"><img src="https://user-images.githubusercontent.com/23121882/37407656-7a2ba57c-279a-11e8-8957-1f85be04d97e.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">The third subplot would be the expected outcome with the axis autoscaled to show all points.</p>
<p dir="auto">One could also argue that plotting negative data on a log scale should not be supported at all,  and that it should be the user's responsibility to make sure the data is positive. In that case however it would make sense to issue a warning instead of just plotting something arbitrary.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Windows 8.1</li>
<li>Matplotlib version: 2.2</li>
<li>Matplotlib backend: any</li>
<li>Python version: 2.7.10</li>
</ul>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, 1)

axs[0].scatter(range(0, 4), [0, 1, 2, 3])
axs[1].scatter(range(0, 4), [0, 1, 2, 3])

axs[0].set_yscale('log')
axs[1].set_yscale('log')

axs[1].set_ylim(bottom=0)

plt.show()"><pre class="notranslate"><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-s1">fig</span>, <span class="pl-s1">axs</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">1</span>)

<span class="pl-s1">axs</span>[<span class="pl-c1">0</span>].<span class="pl-en">scatter</span>(<span class="pl-en">range</span>(<span class="pl-c1">0</span>, <span class="pl-c1">4</span>), [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>])
<span class="pl-s1">axs</span>[<span class="pl-c1">1</span>].<span class="pl-en">scatter</span>(<span class="pl-en">range</span>(<span class="pl-c1">0</span>, <span class="pl-c1">4</span>), [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>])

<span class="pl-s1">axs</span>[<span class="pl-c1">0</span>].<span class="pl-en">set_yscale</span>(<span class="pl-s">'log'</span>)
<span class="pl-s1">axs</span>[<span class="pl-c1">1</span>].<span class="pl-en">set_yscale</span>(<span class="pl-s">'log'</span>)

<span class="pl-s1">axs</span>[<span class="pl-c1">1</span>].<span class="pl-en">set_ylim</span>(<span class="pl-s1">bottom</span><span class="pl-c1">=</span><span class="pl-c1">0</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">This raises</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/home/dstansby/matplotlib/lib/matplotlib/axes/_base.py:3174: UserWarning: Attempted to set non-positive ylimits for log-scale axis; invalid limits will be ignored.
  'Attempted to set non-positive ylimits for log-scale axis; '"><pre class="notranslate"><code class="notranslate">/home/dstansby/matplotlib/lib/matplotlib/axes/_base.py:3174: UserWarning: Attempted to set non-positive ylimits for log-scale axis; invalid limits will be ignored.
  'Attempted to set non-positive ylimits for log-scale axis; '
</code></pre></div>
<p dir="auto">However, the 2nd plot <em>is</em> changed by the <code class="notranslate">set_ylim(bottom=0)</code> call, and no data is visible.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/6197628/21616640/2654ac76-d1da-11e6-800a-96b2027e9947.png"><img src="https://cloud.githubusercontent.com/assets/6197628/21616640/2654ac76-d1da-11e6-800a-96b2027e9947.png" alt="figure_1" style="max-width: 100%;"></a></p>
<p dir="auto">This is present on master.</p>