Skip to content

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

Open

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

Activity

  1. 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[/+] on Jul 19, 2022
  2. scottshambaugh commented on Jul 19, 2022

    @scottshambaugh
    ContributorAuthor

    Somewhat related to #19519

  3. 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[/+] on Apr 2, 2025
  4. scottshambaugh commented on Apr 2, 2025

    @scottshambaugh
    ContributorAuthor

    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.

  5. 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[/+] on Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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