8000 Do not configure axes properties via subplots(..., subplot_kw={...}) · matplotlib/matplotlib@22d0f16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 22d0f16

Browse files
committed
Do not configure axes properties via subplots(..., subplot_kw={...})
While technical possible, this is an anti-pattern IMHO. We should keep Axes creation and customization separate. Extracted from #14411.
1 parent a7b47f4 commit 22d0f16

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

galleries/examples/shapes_and_collections/ellipse_demo.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
angle=np.random.rand() * 360)
2323
for i in range(NUM)]
2424

25-
fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})
25+
fig, ax = plt.subplots()
26+
ax.set(xlim=(0, 10), ylim=(0, 10), aspect="equal")
27+
2628
for e in ells:
2729
ax.add_artist(e)
2830
e.set_clip_box(ax.bbox)
2931
e.set_alpha(np.random.rand())
3032
e.set_facecolor(np.random.rand(3))
3133

32-
ax.set_xlim(0, 10)
33-
ax.set_ylim(0, 10)
34-
3534
plt.show()
3635

3736
# %%
@@ -46,14 +45,12 @@
4645
angles = np.arange(0, 180, angle_step)
4746

4847
fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})
48+
ax.set(xlim=(-2.2, 2.2), ylim=(-2.2, 2.2), aspect="equal")
4949

5050
for angle in angles:
5151
ellipse = Ellipse((0, 0), 4, 2, angle=angle, alpha=0.1)
5252
ax.add_artist(ellipse)
5353

54-
ax.set_xlim(-2.2, 2.2)
55-
ax.set_ylim(-2.2, 2.2)
56-
5754
plt.show()
5855

5956
# %%

0 commit comments

Comments
 (0)
0