Skip to content

FIX: add set_box_aspect, improve tight bounding box for Axes3D + fix bbox_inches support with fixed box_aspect #17515

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

Merged
merged 12 commits into from
Jun 6, 2020
Merged
11 changes: 9 additions & 2 deletions doc/users/next_whats_new/2019-03-25-mplot3d-projection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Plots made with :class:`~mpl_toolkits.mplot3d.axes3d.Axes3D` were previously
stretched to fit a square bounding box. As this stretching was done after
the projection from 3D to 2D, it resulted in distorted images if non-square
bounding boxes were used.
bounding boxes were used. As of 3.3, this no longer occurs.

As of this release, this no longer occurs.
Currently, modes of setting the aspect (via
`~mpl_toolkits.mplot3d.axes3d.Axes3D.set_aspect`) in data space are
not supported for Axes3D but may be in the future. If you want to
simulate having equal aspect in data space, set the ratio of your data
limits to match the value of `~.get_box_aspect`. To control these
ratios use the `~mpl_toolkits.mplot3d.axes3d.Axes3D.set_box_aspect`
method which accepts the ratios as a 3-tuple of X:Y:Z. The default
aspect ratio is 4:4:3.
4 changes: 0 additions & 4 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,10 +1339,6 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
if cbook._str_equal(aspect, 'equal'):
aspect = 1
if not cbook._str_equal(aspect, 'auto'):
if self.name == '3d':
raise NotImplementedError(
'It is not currently possible to manually set the aspect '
'on 3D axes')
aspect = float(aspect) # raise ValueError if necessary

if share:
Expand Down
Loading