Skip to content

Commit 3323b92

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 3323b92

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

galleries/examples/text_labels_and_annotations/fancyarrow_demo.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
Annotation arrow style reference
44
================================
55
6-
Overview of the arrow styles available in `~.Axes.annotate`.
6+
Overview of the available `.ArrowStyle` settings. These are used for the *arrowstyle*
7+
parameter of `~.Axes.annotate` and `.FancyArrowPatch`.
8+
9+
Each style can be configured with a set of parameters, which are stated along with
10+
their default values.
711
"""
812

913
import inspect
@@ -21,29 +25,29 @@
2125
.add_gridspec(1 + nrow, ncol,
2226
wspace=0, hspace=0, left=0, right=1, bottom=0, top=1).subplots())
2327
for ax in axs.flat:
24-
ax.set_xlim(-0.5, 4)
28+
ax.set_xlim(-0.1, 4)
2529
ax.set_axis_off()
2630
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")
31+
ax.text(0, 0.5, "arrowstyle", size="large", color="tab:blue")
32+
ax.text(1.4, .5, "default parameters", size="large")
2933
for ax, (stylename, stylecls) in zip(axs[1:, :].T.flat, styles.items()):
3034
# 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",
35+
l, = ax.plot(1.25, 0, "o", color="darkgrey")
36+
ax.annotate(stylename, (1.25, 0), (0, 0),
37+
size="large", color="tab:blue", va="center", family="monospace",
3438
arrowprops=dict(
35-
arrowstyle=stylename, connectionstyle="arc3,rad=-0.05",
36-
color="k", shrinkA=5, shrinkB=5, patchB=l,
39+
arrowstyle=stylename, connectionstyle="arc3,rad=0",
40+
color="black", shrinkA=5, shrinkB=5, patchB=l,
3741
),
38-
bbox=dict(boxstyle="square", fc="w", ec="grey"))
42+
bbox=dict(boxstyle="square", fc="w", ec="darkgrey"))
3943
# draw default parameters
4044
# wrap at every nth comma (n = 1 or 2, depending on text length)
4145
s = str(inspect.signature(stylecls))[1:-1]
4246
n = 2 if s.count(',') > 3 else 1
43-
ax.text(1.25, 0,
47+
ax.text(1.4, 0,
4448
re.sub(', ', lambda m, c=itertools.count(1): m.group()
4549
if next(c) % n else '\n', s),
46-
verticalalignment="center")
50+
verticalalignment="center", color="0.3")
4751

4852
plt.show()
4953

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