From 23d101a28e00e21723b7718a4fce99a727dff2d9 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:05:01 +0200 Subject: [PATCH] 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. --- .../examples/shapes_and_collections/ellipse_demo.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/galleries/examples/shapes_and_collections/ellipse_demo.py b/galleries/examples/shapes_and_collections/ellipse_demo.py index 22de6998418d..0d7e72a1100d 100644 --- a/galleries/examples/shapes_and_collections/ellipse_demo.py +++ b/galleries/examples/shapes_and_collections/ellipse_demo.py @@ -22,16 +22,15 @@ angle=np.random.rand() * 360) for i in range(NUM)] -fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'}) +fig, ax = plt.subplots() +ax.set(xlim=(0, 10), ylim=(0, 10), aspect="equal") + for e in ells: ax.add_artist(e) e.set_clip_box(ax.bbox) e.set_alpha(np.random.rand()) e.set_facecolor(np.random.rand(3)) -ax.set_xlim(0, 10) -ax.set_ylim(0, 10) - plt.show() # %% @@ -45,15 +44,13 @@ angle_step = 45 # degrees angles = np.arange(0, 180, angle_step) -fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'}) +fig, ax = plt.subplots() +ax.set(xlim=(-2.2, 2.2), ylim=(-2.2, 2.2), aspect="equal") for angle in angles: ellipse = Ellipse((0, 0), 4, 2, angle=angle, alpha=0.1) ax.add_artist(ellipse) -ax.set_xlim(-2.2, 2.2) -ax.set_ylim(-2.2, 2.2) - plt.show() # %%
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: