<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Using version 3.1.0, ax.invert_yaxis() does not work as expected when called on a 3D scatter plot. There seems to be no effect when it is called after populating the plot, while calling it before the plot inverts the data points correctly but moves all ticks to one point.</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="# Version 1: calling invert_yaxis() after populating the plot.
# Version 2 (omitted): calling invert_yaxis() after ax = fig.add_subplot(111, projection='3d')
# Using the official 3D scatter plot example. 

from mpl_toolkits.mplot3d import Axes3D 

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(19680801)

def randrange(n, vmin, vmax):
    '''
    Helper function to make an array of random numbers having shape (n, )
    with each number distributed Uniform(vmin, vmax).
    '''
    return (vmax - vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

n = 100

# For each set of style and range settings, plot n random points in the box
# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].
for m, zlow, zhigh in [('o', -50, -25), ('^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zlow, zhigh)
    ax.scatter(xs, ys, zs, marker=m)

ax.invert_yaxis()
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()"><pre class="notranslate"><span class="pl-c"># Version 1: calling invert_yaxis() after populating the plot.</span>
<span class="pl-c"># Version 2 (omitted): calling invert_yaxis() after ax = fig.add_subplot(111, projection='3d')</span>
<span class="pl-c"># Using the official 3D scatter plot example. </span>

<span class="pl-k">from</span> <span class="pl-s1">mpl_toolkits</span>.<span class="pl-s1">mplot3d</span> <span class="pl-k">import</span> <span class="pl-v">Axes3D</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">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">seed</span>(<span class="pl-c1">19680801</span>)

<span class="pl-k">def</span> <span class="pl-en">randrange</span>(<span class="pl-s1">n</span>, <span class="pl-s1">vmin</span>, <span class="pl-s1">vmax</span>):
    <span class="pl-s">'''</span>
<span class="pl-s">    Helper function to make an array of random numbers having shape (n, )</span>
<span class="pl-s">    with each number distributed Uniform(vmin, vmax).</span>
<span class="pl-s">    '''</span>
    <span class="pl-k">return</span> (<span class="pl-s1">vmax</span> <span class="pl-c1">-</span> <span class="pl-s1">vmin</span>)<span class="pl-c1">*</span><span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">rand</span>(<span class="pl-s1">n</span>) <span class="pl-c1">+</span> <span class="pl-s1">vmin</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">111</span>, <span class="pl-s1">projection</span><span class="pl-c1">=</span><span class="pl-s">'3d'</span>)

<span class="pl-s1">n</span> <span class="pl-c1">=</span> <span class="pl-c1">100</span>

<span class="pl-c"># For each set of style and range settings, plot n random points in the box</span>
<span class="pl-c"># defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].</span>
<span class="pl-k">for</span> <span class="pl-s1">m</span>, <span class="pl-s1">zlow</span>, <span class="pl-s1">zhigh</span> <span class="pl-c1">in</span> [(<span class="pl-s">'o'</span>, <span class="pl-c1">-</span><span class="pl-c1">50</span>, <span class="pl-c1">-</span><span class="pl-c1">25</span>), (<span class="pl-s">'^'</span>, <span class="pl-c1">-</span><span class="pl-c1">30</span>, <span class="pl-c1">-</span><span class="pl-c1">5</span>)]:
    <span class="pl-s1">xs</span> <span class="pl-c1">=</span> <span class="pl-en">randrange</span>(<span class="pl-s1">n</span>, <span class="pl-c1">23</span>, <span class="pl-c1">32</span>)
    <span class="pl-s1">ys</span> <span class="pl-c1">=</span> <span class="pl-en">randrange</span>(<span class="pl-s1">n</span>, <span class="pl-c1">0</span>, <span class="pl-c1">100</span>)
    <span class="pl-s1">zs</span> <span class="pl-c1">=</span> <span class="pl-en">randrange</span>(<span class="pl-s1">n</span>, <span class="pl-s1">zlow</span>, <span class="pl-s1">zhigh</span>)
    <span class="pl-s1">ax</span>.<span class="pl-en">scatter</span>(<span class="pl-s1">xs</span>, <span class="pl-s1">ys</span>, <span class="pl-s1">zs</span>, <span class="pl-s1">marker</span><span class="pl-c1">=</span><span class="pl-s1">m</span>)

<span class="pl-s1">ax</span>.<span class="pl-en">invert_yaxis</span>()
<span class="pl-s1">ax</span>.<span class="pl-en">set_xlabel</span>(<span class="pl-s">'X Label'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_ylabel</span>(<span class="pl-s">'Y Label'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_zlabel</span>(<span class="pl-s">'Z Label'</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome when inverting axis after populating plot:</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15879839/59764142-727ea780-929b-11e9-9620-e7b21cf54dbd.png"><img src="https://user-images.githubusercontent.com/15879839/59764142-727ea780-929b-11e9-9620-e7b21cf54dbd.png" alt="Figure_0" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Actual outcome when inverting axis before populating plot:</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15879839/59764401-018bbf80-929c-11e9-954c-aaed719dc34e.png"><img src="https://user-images.githubusercontent.com/15879839/59764401-018bbf80-929c-11e9-954c-aaed719dc34e.png" alt="Figure_1" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">Using ax.set_ylim(105,-5):</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15879839/59764658-81b22500-929c-11e9-874c-64f54fe2f537.png"><img src="https://user-images.githubusercontent.com/15879839/59764658-81b22500-929c-11e9-874c-64f54fe2f537.png" alt="Figure_2" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Ubuntu 18.04.2</li>
<li>Matplotlib version: 3.1.0</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): TkAgg</li>
<li>Python version: 3.6.8</li>
<li>Jupyter version (if applicable):</li>
<li>Other libraries: Numpy 1.16.1</li>
</ul>
<p dir="auto">Matplotlib and Python were installed with pip.</p>
<hr>
<p dir="auto">Also posted on SO, <a href="https://stackoverflow.com/questions/56666916/inverting-axis-of-matplotlib-3d-plot-ruins-ticks" rel="nofollow">https://stackoverflow.com/questions/56666916/inverting-axis-of-matplotlib-3d-plot-ruins-ticks</a></p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">The ax.invertxaxis() and ax.invert_yaxis() function both produce the same output, a scatterplot with a flipped X axis.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt

ax = plt.axes(projection='3d')
plt.title(&quot;Invert Z&quot;)
ax.scatter3D(1,1,1)
# ax.invert_xaxis()
ax.invert_yaxis()
# ax.invert_zaxis()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">mpl_toolkits</span> <span class="pl-k">import</span> <span class="pl-s1">mplot3d</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-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">axes</span>(<span class="pl-s1">projection</span><span class="pl-c1">=</span><span class="pl-s">'3d'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">title</span>(<span class="pl-s">"Invert Z"</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">scatter3D</span>(<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)
<span class="pl-c"># ax.invert_xaxis()</span>
<span class="pl-s1">ax</span>.<span class="pl-en">invert_yaxis</span>()
<span class="pl-c"># ax.invert_zaxis()</span></pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">No inversions:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/35809470/137531316-0b630f80-6077-436e-9af3-78e473c634b5.png"><img src="https://user-images.githubusercontent.com/35809470/137531316-0b630f80-6077-436e-9af3-78e473c634b5.png" alt="Screen Shot 2021-10-15 at 1 52 25 PM" style="max-width: 100%;"></a></p>
<p dir="auto">X Inversion:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/35809470/137531353-e30e4400-9821-4edb-b760-c39b1967cdf2.png"><img src="https://user-images.githubusercontent.com/35809470/137531353-e30e4400-9821-4edb-b760-c39b1967cdf2.png" alt="Screen Shot 2021-10-15 at 1 52 48 PM" style="max-width: 100%;"></a></p>
<p dir="auto">Y Inversion:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/35809470/137531630-2c4ef7bf-cadc-44fb-a633-5e22cda5b4f9.png"><img src="https://user-images.githubusercontent.com/35809470/137531630-2c4ef7bf-cadc-44fb-a633-5e22cda5b4f9.png" alt="Screen Shot 2021-10-15 at 1 54 55 PM" style="max-width: 100%;"></a></p>
<p dir="auto">Z Inversion behaves as expected:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/35809470/137531781-c01d7b74-fb60-4926-b72c-ec7e86580537.png"><img src="https://user-images.githubusercontent.com/35809470/137531781-c01d7b74-fb60-4926-b72c-ec7e86580537.png" alt="Screen Shot 2021-10-15 at 1 56 10 PM" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">I would expect the y axis to be inverted</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.2.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Python version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Other libraries</h3>
<p dir="auto">mpl_toolkits.mplot3d</p>
<h3 dir="auto">Installation</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Conda channel</h3>
<p dir="auto"><em>No response</em></p>