Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Calling invert_yaxis() on a 3D plot has either no effect or removes ticks #14577

Copy link
Copy link
Closed
@ffaallkk

Description

@ffaallkk
Issue body actions

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:

Figure_0

Actual outcome when inverting axis before populating plot:

Figure_1

Expected outcome

Using ax.set_ylim(105,-5):

Figure_2

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

No one assigned

    Labels

    Release criticalFor 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.topic: mplot3d

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.