Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0322e9

Browse files
authored
Merge pull request#29819 from meeseeksmachine/auto-backport-of-pr-29801-on-v3.10.1-doc
Backport PR#29801 on branch v3.10.1-doc (DOC: Slightly further improve arrowstyle demo)
2 parents6f5399a +588365a commitf0322e9

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

‎galleries/examples/text_labels_and_annotations/fancyarrow_demo.py

Lines changed: 21 additions & 17 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
importinspect
@@ -12,38 +16,38 @@
1216

1317
importmatplotlib.pyplotasplt
1418

15-
importmatplotlib.patchesasmpatches
19+
frommatplotlib.patchesimportArrowStyle
1620

17-
styles=mpatches.ArrowStyle.get_styles()
21+
styles=ArrowStyle.get_styles()
1822
ncol=2
1923
nrow= (len(styles)+1)//ncol
20-
axs=(plt.figure(figsize=(4*ncol,1+nrow))
21-
.add_gridspec(1+nrow,ncol,
22-
wspace=0,hspace=0,left=0,right=1,bottom=0,top=1).subplots())
24+
gridspec_kw=dict(wspace=0,hspace=0.05,left=0,right=1,bottom=0,top=1)
25+
fig,axs=plt.subplots(1+nrow,ncol,
26+
figsize=(4*ncol,1+nrow),gridspec_kw=gridspec_kw)
2327
foraxinaxs.flat:
24-
ax.set_xlim(-0.5,4)
28+
ax.set_xlim(-0.1,4)
2529
ax.set_axis_off()
2630
foraxinaxs[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
forax, (stylename,stylecls)inzip(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=2ifs.count(',')>3else1
43-
ax.text(1.25,0,
47+
ax.text(1.4,0,
4448
re.sub(', ',lambdam,c=itertools.count(1):m.group()
4549
ifnext(c)%nelse'\n',s),
46-
verticalalignment="center")
50+
verticalalignment="center",color="0.3")
4751

4852
plt.show()
4953

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp