Skip to content

Commit d48b87c

Browse files
tacaswellQuLogic
andcommitted
MNT: suggestions from review
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent 390a57a commit d48b87c

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

doc/users/next_whats_new/2019-03-25-mplot3d-projection.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ bounding boxes were used. As of 3.3, this no longer occurs.
88

99
Currently modes of setting the aspect (via
1010
`~mpl_toolkits.mplot3d.axes3d.Axes3D.set_aspect`), in data space, are
11-
not supported for Axes3D but maybe in the future. If you want to
11+
not supported for Axes3D but may be in the future. If you want to
1212
simulate having equal aspect in data space, set the ratio of your data
1313
limits to match the value of `~.get_box_aspect`. To control these
1414
ratios use the `~mpl_toolkits.mplot3d.axes3d.Axes3D.set_box_aspect`
15-
method which accepts th ratios at as a 3-tuple of X:Y:Z. The default
15+
method which accepts th ratios as a 3-tuple of X:Y:Z. The default
1616
aspect ratio is 4:4:3.

lib/mpl_toolkits/mplot3d/axes3d.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,17 @@ def set_anchor(self, anchor, share=False):
349349
ax._anchor = anchor
350350
ax.stale = True
351351

352-
def set_box_aspect(self, aspect, zoom=1):
352+
def set_box_aspect(self, aspect, *, zoom=1):
353353
"""
354354
Set the axes box aspect.
355355
356356
The box aspect is the ratio of the axes height to the axes width in
357357
physical units. This is not to be confused with the data
358358
aspect, set via `~.Axes.set_aspect`.
359359
360+
The *zoom* is a Axes3D only parameter that controls the overall
361+
size of the Axes3D in the figure.
362+
360363
Parameters
361364
----------
362365
aspect : 3-tuple of floats on None
@@ -370,7 +373,7 @@ def set_box_aspect(self, aspect, zoom=1):
370373
ax.set_box_aspect(aspect=(4, 4, 3), zoom=1)
371374
372375
zoom : float
373-
Control the "zoom" of the
376+
Control overall size of the Axes3D in the figure.
374377
375378
See Also
376379
--------
@@ -381,7 +384,7 @@ def set_box_aspect(self, aspect, zoom=1):
381384
aspect = zoom * np.asarray((4, 4, 3)) / 3.5
382385
else:
383386
aspect = np.asarray(aspect, dtype=float)
384-
# default scale tuned to match the
387+
# default scale tuned to match the mpl32 appearance.
385388
aspect *= 1.829 * zoom / np.linalg.norm(aspect)
386389

387390
self._box_aspect = aspect
@@ -391,8 +394,6 @@ def apply_aspect(self, position=None):
391394
if position is None:
392395
position = self.get_position(original=True)
393396

394-
aspect = self.get_aspect()
395-
396397
# in the superclass, we would go through and actually deal with axis
397398
# scales and box/datalim. Those are all irrelevant - all we need to do
398399
# is make sure our coordinate system is square.
@@ -463,7 +464,6 @@ def get_axis_position(self):
463464
return xhigh, yhigh, zhigh
464465

465466
def _on_units_changed(self, scalex=False, scaley=False, scalez=False):
466-
467467
"""
468468
Callback for processing changes to axis units.
469469

lib/mpl_toolkits/mplot3d/axis3d.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Parts rewritten by Reinier Heeres <reinier@heeres.eu>
44

55
import numpy as np
6+
67
import matplotlib.transforms as mtransforms
78
from matplotlib import (
89
artist, lines as mlines, axis as maxis, patches as mpatches, rcParams)

lib/mpl_toolkits/tests/test_mplot3d.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ def test_equal_box_aspect():
975975
v = np.linspace(0, np.pi, 100)
976976
x = np.outer(np.cos(u), np.sin(v))
977977
y = np.outer(np.sin(u), np.sin(v))
978-
z = np.outer(np.ones(np.size(u)), np.cos(v))
978+
z = np.outer(np.ones_like(u), np.cos(v))
979979

980980
# Plot the surface
981981
ax.plot_surface(x, y, z)
@@ -987,7 +987,9 @@ def test_equal_box_aspect():
987987
ax.plot3D(*zip(s, e), color="b")
988988

989989
# Make axes limits
990-
xyzlim = np.array([ax.get_xlim3d(), ax.get_ylim3d(), ax.get_zlim3d()]).T
990+
xyzlim = np.column_stack(
991+
[ax.get_xlim3d(), ax.get_ylim3d(), ax.get_zlim3d()]
992+
)
991993
XYZlim = [min(xyzlim[0]), max(xyzlim[1])]
992994
ax.set_xlim3d(XYZlim)
993995
ax.set_ylim3d(XYZlim)

0 commit comments

Comments
 (0)