Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit daf44a6

Browse files
Update whats new
1 parent 99c43af commit daf44a6

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Set equal aspect ratio for 3D plots
2+
-----------------------------------
3+
4+
Users can set the aspect ratio for the X, Y, Z axes of a 3D plot to be 'equal',
5+
'equalxy', 'equalxz', or 'equalyz' rather than the default of 'auto'.
6+
7+
.. plot::
8+
:include-source: true
9+
10+
aspects = ('auto', 'equal', 'equalxy', 'equalyz', 'equalxz')
11+
fig, axs = plt.subplots(1, len(aspects), subplot_kw={'projection': '3d'})
12+
13+
# Draw rectangular cuboid with side lengths [1, 1, 2]
14+
r = [0, 1]
15+
scale = np.array([1, 1, 2])
16+
pts = itertools.combinations(np.array(list(itertools.product(r, r, r))), 2)
17+
for start, end in pts:
18+
if np.sum(np.abs(start - end)) == r[1] - r[0]:
19+
for ax in axs:
20+
ax.plot3D(*zip(start*scale, end*scale), color='C0')
21+
22+
# Set the aspect ratios
23+
for i, ax in enumerate(axs):
24+
ax.set_box_aspect((3, 4, 5))
25+
ax.set_aspect(aspects[i])
26+
ax.title(f"set_aspect('{aspects[i]}')")
27+
28+
plt.show()

doc/users/next_whats_new/3d_plot_axis_equal.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)