Closed
Closed
Copy link
Description
Bug report
Bug summary
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.
Code for reproduction
# 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()
Actual outcome when inverting axis after populating plot:
Actual outcome when inverting axis before populating plot:
Expected outcome
Using ax.set_ylim(105,-5):
Matplotlib version
- Operating system: Ubuntu 18.04.2
- Matplotlib version: 3.1.0
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.6.8
- Jupyter version (if applicable):
- Other libraries: Numpy 1.16.1
Matplotlib and Python were installed with pip.
Also posted on SO, https://stackoverflow.com/questions/56666916/inverting-axis-of-matplotlib-3d-plot-ruins-ticks
Metadata
Metadata
Assignees
Labels
For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.