From f21219be5f7411a38b1598382f16dd7b099ffa9e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 17 Nov 2022 23:35:11 +0100 Subject: [PATCH] DOC: Remove text rotation example The content is duplicate to the "Text rotation mode" example and the latter has a better and more complete description. --- .../demo_text_rotation_mode.py | 2 + .../text_rotation.py | 49 ------------------- 2 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 examples/text_labels_and_annotations/text_rotation.py diff --git a/examples/text_labels_and_annotations/demo_text_rotation_mode.py b/examples/text_labels_and_annotations/demo_text_rotation_mode.py index 690dca6ad4ef..8920cb543162 100644 --- a/examples/text_labels_and_annotations/demo_text_rotation_mode.py +++ b/examples/text_labels_and_annotations/demo_text_rotation_mode.py @@ -17,6 +17,8 @@ the bounding box of the rotated text. - ``rotation_mode='anchor'`` aligns the unrotated text and then rotates the text around the point of alignment. + +.. redirect-from:: /gallery/text_labels_and_annotations/text_rotation """ import matplotlib.pyplot as plt diff --git a/examples/text_labels_and_annotations/text_rotation.py b/examples/text_labels_and_annotations/text_rotation.py deleted file mode 100644 index a380fc324bed..000000000000 --- a/examples/text_labels_and_annotations/text_rotation.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -=================================== -Default text rotation demonstration -=================================== - -The way Matplotlib does text layout by default is counter-intuitive to some, so -this example is designed to make it a little clearer. - -The text is aligned by its bounding box (the rectangular box that surrounds the -ink rectangle). The order of operations is rotation then alignment. -Basically, the text is centered at your (x, y) location, rotated around this -point, and then aligned according to the bounding box of the rotated text. - -So if you specify left, bottom alignment, the bottom left of the -bounding box of the rotated text will be at the (x, y) coordinate of the text. - -But a picture is worth a thousand words! -""" - -import matplotlib.pyplot as plt -import numpy as np - - -def addtext(ax, props): - ax.text(0.5, 0.5, 'text 0', props, rotation=0) - ax.text(1.5, 0.5, 'text 45', props, rotation=45) - ax.text(2.5, 0.5, 'text 135', props, rotation=135) - ax.text(3.5, 0.5, 'text 225', props, rotation=225) - ax.text(4.5, 0.5, 'text -45', props, rotation=-45) - for x in range(0, 5): - ax.scatter(x + 0.5, 0.5, color='r', alpha=0.5) - ax.set_yticks([0, .5, 1]) - ax.set_xticks(np.arange(0, 5.1, 0.5)) - ax.set_xlim(0, 5) - ax.grid(True) - - -# the text bounding box -bbox = {'fc': '0.8', 'pad': 0} - -fig, axs = plt.subplots(2, 1, sharex=True) - -addtext(axs[0], {'ha': 'center', 'va': 'center', 'bbox': bbox}) -axs[0].set_ylabel('center / center') - -addtext(axs[1], {'ha': 'left', 'va': 'bottom', 'bbox': bbox}) -axs[1].set_ylabel('left / bottom') - -plt.show()