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

Commit138145a

Browse files
committed
Add explanatory comments for text rotation example
1 parent6013532 commit138145a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

‎examples/text_labels_and_annotations/demo_text_rotation_mode.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
"""
2-
=======================
1+
"""=======================
32
Demo Text Rotation Mode
43
=======================
54
5+
The axes' method `~.axes.Axes.text` takes an argument ``rotation_mode`` that
6+
controls the alignment and rotation of the text. If ``rotation_mode`` is
7+
``None`` or ``default`` the text will first be rotated and then aligned
8+
according to the horizontal and vertical alignments (``ha`` and ``va`` in the
9+
example). If ``rotation_mode`` is ``anchor`` the text is aligned before rotation.
10+
611
"""
12+
importmatplotlib
713
frommpl_toolkits.axes_grid1.axes_gridimportImageGrid
814

915

@@ -19,18 +25,23 @@ def test_rotation_mode(fig, mode, subplot_location):
1925
forha,axinzip(ha_list,grid.axes_row[-1]):
2026
ax.axis["bottom"].label.set_text(ha)
2127

28+
# create a grid of axes to display text on.
2229
grid.axes_row[0][1].set_title(mode,size="large")
2330

2431
forva,axinzip(va_list,grid.axes_column[0]):
2532
ax.axis["left"].label.set_text(va)
2633

34+
# use a different horizontal and vertical alignment for the text in each
35+
# axes.
2736
i=0
2837
forvainva_list:
2938
forhainha_list:
3039
ax=grid[i]
3140
foraxisinax.axis.values():
3241
axis.toggle(ticks=False,ticklabels=False)
3342

43+
# add text to the axes. Set the rotation_mode, horizontal
44+
# alignment (ha) and vertical alignment (va).
3445
ax.text(0.5,0.5,"Tpg",
3546
size="large",rotation=40,
3647
bbox=dict(boxstyle="square,pad=0.",
@@ -48,3 +59,16 @@ def test_rotation_mode(fig, mode, subplot_location):
4859
test_rotation_mode(fig,"default",121)
4960
test_rotation_mode(fig,"anchor",122)
5061
plt.show()
62+
63+
64+
#############################################################################
65+
#
66+
# ------------
67+
#
68+
# References
69+
# """"""""""
70+
#
71+
# The use of the following method is shown in this example:
72+
73+
74+
matplotlib.axes.Axes.text

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp