diff --git a/lib/matplotlib/tests/baseline_images/rotation_center_baseline.png b/lib/matplotlib/tests/baseline_images/rotation_center_baseline.png new file mode 100644 index 000000000000..c6ea8bd01d53 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/rotation_center_baseline.png differ diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 1fbbf864e25c..b4dde5cd12b6 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -709,3 +709,14 @@ def test_update_mutate_input(): t.update(inp) assert inp['fontproperties'] == cache['fontproperties'] assert inp['bbox'] == cache['bbox'] + +@image_comparison(['rotation_center_baseline.png']) +def test_rotation(): + plt.plot([0, 1], lw=0) + plt.axvline(.5, linewidth=.5, color='.5') + plt.axhline(.5, linewidth=.5, color='.5') + N = 4 + r = 0 + plt.text(.5, .5, 'pP', size=100, rotation=r/N*360, va='center_baseline', rotation_mode='anchor') + r = 2 + plt.text(.5, .5, 'pP', size=100, rotation=r/N*360, va='center_baseline', rotation_mode='anchor') diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 78a6ad8b104c..0a101b1cd809 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -423,7 +423,7 @@ def _get_layout(self, renderer): elif valign == 'baseline': offsety = ymax1 - baseline elif valign == 'center_baseline': - offsety = ymax1 - baseline / 2.0 + offsety = ymax1 - baseline - ymin1 else: offsety = ymin1