Skip to content

Commit 299313d

Browse files
committed
DOC: Slightly further improve arrowstyle demo
- use straight lines - use monospace font for the style names - adjust positions and colors so that the arrows stand out more
1 parent a9dc9ac commit 299313d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

galleries/examples/text_labels_and_annotations/fancyarrow_demo.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,30 @@
2121
.add_gridspec(1 + nrow, ncol,
2222
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)
24+
ax.set_xlim(-0.1, 4)
2525
ax.set_axis_off()
2626
for ax in axs[0, :]:
27-
ax.text(-0.25, 0.5, "arrowstyle", size="large", color="tab:blue")
28-
ax.text(1.25, .5, "default parameters", size="large")
27+
ax.text(0, 0.5, "arrowstyle", size="large", color="tab:blue")
28+
ax.text(1.4, .5, "default parameters", size="large")
2929
for ax, (stylename, stylecls) in zip(axs[1:, :].T.flat, styles.items()):
3030
# 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",
31+
l, = ax.plot(1.25, 0, "o", color="lightgrey")
32+
ax.annotate(stylename, (1.25, 0), (0, 0),
33+
size="large", color="tab:blue", ha="left", va="center",
34+
family="monospace",
3435
arrowprops=dict(
35-
arrowstyle=stylename, connectionstyle="arc3,rad=-0.05",
36+
arrowstyle=stylename, connectionstyle="arc3,rad=0",
3637
color="k", shrinkA=5, shrinkB=5, patchB=l,
3738
),
38-
bbox=dict(boxstyle="square", fc="w", ec="grey"))
39+
bbox=dict(boxstyle="square", fc="w", ec="lightgrey"))
3940
# draw default parameters
4041
# wrap at every nth comma (n = 1 or 2, depending on text length)
4142
s = str(inspect.signature(stylecls))[1:-1]
4243
n = 2 if s.count(',') > 3 else 1
43-
ax.text(1.25, 0,
44+
ax.text(1.4, 0,
4445
re.sub(', ', lambda m, c=itertools.count(1): m.group()
4546
if next(c) % n else '\n', s),
46-
verticalalignment="center")
47+
verticalalignment="center", color="0.3")
4748

4849
plt.show()
4950

0 commit comments

Comments
 (0)