Skip to content

[Bug]: 3D artist clipbox cuts off data sooner than axis panes/spines/etc #23450

Open
@scottshambaugh

Description

@scottshambaugh

Bug summary

When enlarging 3D plots with ax.set_box_aspect(None, zoom=zoom), there is a mismatch between the limits of rendering data and the axis planes. These should be aligned.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
from itertools import product, combinations

fig, ax = plt.subplots(1, 1, subplot_kw={'projection': '3d'})

r = [0, 1]
scale = np.array([1, 1, 2])
# Draw rectangular cuboid with side lengths [1, 1, 2]
for start, end in combinations(np.array(list(product(r, r, r))), 2):
    if np.sum(np.abs(start - end)) == r[1] - r[0]:
        ax.plot3D(*zip(start*scale, end*scale))

ax.view_init(elev=7, azim=35, roll=45)
ax.set_box_aspect(None, zoom=1.25)
ax.set_proj_type('ortho')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')

Actual outcome

image

Expected outcome

I would expect either the corners of the plotted box to be included, or the corners of the axis planes to be cut off. Ideally the first one.

Additional information

Stackoverflow with the same issue: https://stackoverflow.com/questions/74733826/matplotlib-invisible-margins-cutting-off-3d-plot-data

Operating system

No response

Matplotlib Version

3.6.0.dev2960+g51ce6776b1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions