Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scottshambaugh opened this issue Jul 19, 2022 · 2 comments

Comments

@scottshambaugh
Copy link
Contributor

scottshambaugh commented Jul 19, 2022

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

@scottshambaugh scottshambaugh changed the title [Bug]: Data clip box not aligned with axis planes when [Bug]: Data clip box not aligned with axis planes when 3d plot box aspect is enlargened Jul 19, 2022
@scottshambaugh
Copy link
Contributor Author

scottshambaugh commented Jul 19, 2022

Somewhat related to #19519

@scottshambaugh scottshambaugh changed the title [Bug]: Data clip box not aligned with axis planes when 3d plot box aspect is enlargened [Bug]: 3D artist clipbox is more restrictive than axis panes/ticks/spines/lables Apr 2, 2025
@scottshambaugh
Copy link
Contributor Author

scottshambaugh commented Apr 2, 2025

This is really a broader issue of 3D date being clipped too restrictively in general, like in #19519 (comment) or #19519 (comment) or https://stackoverflow.com/questions/74733826/matplotlib-invisible-margins-cutting-off-3d-plot-data. I believe the fix will be to make sure the clip boxes for each of the 3D artists expand to the whole subplot.

@scottshambaugh scottshambaugh changed the title [Bug]: 3D artist clipbox is more restrictive than axis panes/ticks/spines/lables [Bug]: 3D artist clipbox cuts off data sooner than axis panes/spines/etc Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants