Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fce978f

Browse files
committed
Add explanatory comments for text rotation example
1 parent 6013532 commit fce978f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/text_labels_and_annotations/demo_text_rotation_mode.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
Demo Text Rotation Mode
44
=======================
55
6+
The axes method text takes an argument rotation_mode that controls the
7+
alignment and rotation of the text. If rotation_mode is None or "default" the
8+
text will first be rotated and then aligned according to the horizontal and
9+
vertical alignments (ha and va in the example). If rotation_mode is "anchor"
10+
the text is aligned before rotation.
11+
612
"""
13+
import matplotlib
714
from mpl_toolkits.axes_grid1.axes_grid import ImageGrid
815

916

@@ -19,18 +26,23 @@ def test_rotation_mode(fig, mode, subplot_location):
1926
for ha, ax in zip(ha_list, grid.axes_row[-1]):
2027
ax.axis["bottom"].label.set_text(ha)
2128

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

2432
for va, ax in zip(va_list, grid.axes_column[0]):
2533
ax.axis["left"].label.set_text(va)
2634

35+
# use a different horizontal and vertical alignment for the text in each
36+
# axes.
2737
i = 0
2838
for va in va_list:
2939
for ha in ha_list:
3040
ax = grid[i]
3141
for axis in ax.axis.values():
3242
axis.toggle(ticks=False, ticklabels=False)
3343

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

0 commit comments

Comments
 (0)