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

Commit66401c4

Browse files
committed
DOC: Cleanup text rotation in data coordinates example
1 parent067b77c commit66401c4

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

‎galleries/examples/text_labels_and_annotations/text_rotation_relative_to_line.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,18 @@
1515
"""
1616

1717
importmatplotlib.pyplotasplt
18-
importnumpyasnp
1918

2019
fig,ax=plt.subplots()
2120

22-
# Plot diagonal line (45 degrees)
23-
h=ax.plot(range(0,10),range(0,10))
24-
25-
# set limits so that it no longer looks on screen to be 45 degrees
26-
ax.set_xlim([-10,20])
27-
28-
# Locations to plot text
29-
l1=np.array((1,1))
30-
l2=np.array((5,5))
31-
32-
# Rotate angle
33-
angle=45
21+
# Plot diagonal line (45 degrees in data coordinates)
22+
ax.plot(range(0,8),range(0,8))
23+
ax.set_xlim([-10,10])
3424

3525
# Plot text
36-
th1=ax.text(*l1,'textnot rotated correctly',fontsize=16,
37-
rotation=angle,rotation_mode='anchor')
38-
th2=ax.text(*l2,'textrotated correctly',fontsize=16,
39-
rotation=angle,rotation_mode='anchor',
40-
transform_rotates_text=True)
26+
ax.text(-8,0,'text45° in screen coordinates',fontsize=18,
27+
rotation=45,rotation_mode='anchor')
28+
ax.text(0,0,'text45° in data coordinates',fontsize=18,
29+
rotation=45,rotation_mode='anchor',
30+
transform_rotates_text=True)
4131

4232
plt.show()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp