Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mplot3d: scatter (and others) incorrectly auto-scale axes after set_[xyz]lim() #783

Closed
@zpincus

Description

@zpincus

The 2d plot functions have some state variables so that if the axes have been manually re-scaled using the set_[xy]lim() functions (or wrappers around them), calling a plot function (like scatter) won't re-scale the axes.

This functionality appears to be missing / inactive in 3d plots:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

ax = plt.axes(projection='3d')
ax.set_xlim(0,10)
ax.set_ylim(3,7)
ax.set_zlim(-5,15)
ax.scatter([4,5,6],[5,4,6],[6,5,4])
plt.show()

Note that the manually-set limits are no longer respected. Compare to the 2d case, where this works:

import matplotlib.pyplot as plt

ax = plt.axes()
ax.set_xlim(0,10)
ax.set_ylim(3,7)
ax.scatter([4,5,6],[5,4,6])
plt.show()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions