Skip to content

Commit 7b5e45e

Browse files
authored
Merge pull request #29787 from meeseeksmachine/auto-backport-of-pr-29755-on-v3.10.1-doc
Backport PR #29755 on branch v3.10.1-doc (DOC: Simplify annotation arrow style reference)
2 parents b925652 + 77c8cf3 commit 7b5e45e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

galleries/examples/text_labels_and_annotations/fancyarrow_demo.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,31 @@
1919
nrow = (len(styles) + 1) // ncol
2020
axs = (plt.figure(figsize=(4 * ncol, 1 + nrow))
2121
.add_gridspec(1 + nrow, ncol,
22-
wspace=.7, left=.1, right=.9, bottom=0, top=1).subplots())
22+
wspace=0, hspace=0, left=0, right=1, bottom=0, top=1).subplots())
2323
for ax in axs.flat:
24+
ax.set_xlim(-0.5, 4)
2425
ax.set_axis_off()
2526
for ax in axs[0, :]:
26-
ax.text(0, .5, "arrowstyle",
27-
transform=ax.transAxes, size="large", color="tab:blue",
28-
horizontalalignment="center", verticalalignment="center")
29-
ax.text(.35, .5, "default parameters",
30-
transform=ax.transAxes,
31-
horizontalalignment="left", verticalalignment="center")
27+
ax.text(-0.25, 0.5, "arrowstyle", size="large", color="tab:blue")
28+
ax.text(1.25, .5, "default parameters", size="large")
3229
for ax, (stylename, stylecls) in zip(axs[1:, :].T.flat, styles.items()):
33-
l, = ax.plot(.25, .5, "ok", transform=ax.transAxes)
34-
ax.annotate(stylename, (.25, .5), (-0.1, .5),
35-
xycoords="axes fraction", textcoords="axes fraction",
36-
size="large", color="tab:blue",
37-
horizontalalignment="center", verticalalignment="center",
30+
# draw dot and annotation with arrowstyle
31+
l, = ax.plot(1, 0, "o", color="grey")
32+
ax.annotate(stylename, (1, 0), (0, 0),
33+
size="large", color="tab:blue", ha="center", va="center",
3834
arrowprops=dict(
3935
arrowstyle=stylename, connectionstyle="arc3,rad=-0.05",
4036
color="k", shrinkA=5, shrinkB=5, patchB=l,
4137
),
42-
bbox=dict(boxstyle="square", fc="w"))
38+
bbox=dict(boxstyle="square", fc="w", ec="grey"))
39+
# draw default parameters
4340
# wrap at every nth comma (n = 1 or 2, depending on text length)
4441
s = str(inspect.signature(stylecls))[1:-1]
4542
n = 2 if s.count(',') > 3 else 1
46-
ax.text(.35, .5,
43+
ax.text(1.25, 0,
4744
re.sub(', ', lambda m, c=itertools.count(1): m.group()
4845
if next(c) % n else '\n', s),
49-
transform=ax.transAxes,
50-
horizontalalignment="left", verticalalignment="center")
46+
verticalalignment="center")
5147

5248
plt.show()
5349

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy