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

Skip to content

Commit 59c170b

Browse files
committed
Avoid ax.texts in rotation demo
1 parent feda7e6 commit 59c170b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/text_labels_and_annotations/demo_text_rotation_mode.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def test_rotation_mode(fig, mode, subplot_location):
5050
{"bbox": dict(boxstyle="square,pad=0.", ec="none", fc="C1", alpha=0.3)}
5151
)
5252

53+
texts = {}
54+
5355
# use a different text alignment in each axes
5456
for i, va in enumerate(va_list):
5557
for j, ha in enumerate(ha_list):
@@ -64,12 +66,12 @@ def test_rotation_mode(fig, mode, subplot_location):
6466
size="x-large", rotation=40,
6567
horizontalalignment=ha, verticalalignment=va,
6668
rotation_mode=mode, **kw)
69+
texts[ax] = tx
6770

6871
if mode == "default":
6972
# highlight bbox
7073
fig.canvas.draw()
71-
for ax in axs.flat:
72-
text, = ax.texts
74+
for ax, text in texts.items():
7375
bb = text.get_window_extent().transformed(ax.transData.inverted())
7476
rect = plt.Rectangle((bb.x0, bb.y0), bb.width, bb.height,
7577
facecolor="C1", alpha=0.3, zorder=2)

0 commit comments

Comments
 (0)