8000 [Bug]: vertical_axis not respected when rotating plots interactively · Issue #28040 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: vertical_axis not respected when rotating plots interactively #28040
Closed
@Illviljan

Description

@Illviljan

Bug summary

When setting ax.view_init(vertical_axis="x") the plot is initialized as intended but once rotating it a little the plot and ax._vertical_axis is reset to the default value.

Code for reproduction

x = np.array([0, 1, 2, 4])
y = np.array([5, 10])
z = np.array([100, 150, 200])
X, Y, Z = np.meshgrid(*[x, y, z], indexing="ij")
c = np.arange(0, X.size)

plt.figure()
for j, (a, e) in enumerate([(0, 0), (-60, 30)]):
    for i, vert_a in enumerate(["z", "y", "x"]):
        ax = plt.subplot(2, 3, j * 3 + 1 + i, projection="3d")
        pc = ax.scatter(X, Y, Z, c=c)
        # ax.view_init(vertical_axis=vert_a)
        # ax.view_init(azim=0, elev=0, vertical_axis=vert_a)
        # ax.view_init(azim=-60, elev=30, vertical_axis=vert_a)
        ax.view_init(azim=a, elev=e, vertical_axis=vert_a)
        ax.set_title(f"azim={a}, elev={e}, vertical_axis='{vert_a}'")
        ax.set_xlabel("x")
        ax.set_ylabel("y")
        ax.set_zlabel("z")

Actual outcome

Inital view:
image

After a small rotation on the bottom right plot:
image

Expected outcome

ax._vertical_axis should stay the same when rotating plots. This worked correctly in earlier matplotlib version.

Additional information

No response

Operating system

Windows 10

Matplotlib Version

3.8.3

Matplotlib Backend

Qt5Agg

Python version

3.12

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0