diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 19e00be77c5b..c26edeb55abd 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -349,6 +349,19 @@ def test_get_rotation_mod360(): assert_almost_equal(text.get_rotation(i), j) +@pytest.mark.parametrize("ha", ["center", "right", "left"]) +@pytest.mark.parametrize("va", ["center", "top", "bottom", + "baseline", "center_baseline"]) +def test_null_rotation_with_rotation_mode(ha, va): + fig, ax = plt.subplots() + kw = dict(rotation=0, va=va, ha=ha) + t0 = ax.text(.5, .5, 'test', rotation_mode='anchor', **kw) + t1 = ax.text(.5, .5, 'test', rotation_mode='default', **kw) + fig.canvas.draw() + assert_almost_equal(t0.get_window_extent(fig.canvas.renderer).get_points(), + t1.get_window_extent(fig.canvas.renderer).get_points()) + + @image_comparison(baseline_images=['text_bboxclip']) def test_bbox_clipping(): plt.text(0.9, 0.2, 'Is bbox clipped?', backgroundcolor='r', clip_on=True) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 7cd48ef06b6a..528d0197e978 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -403,7 +403,7 @@ def _get_layout(self, renderer): elif valign == 'baseline': offsety = ymax1 - baseline elif valign == 'center_baseline': - offsety = (ymin1 + ymax1 - baseline) / 2.0 + offsety = ymax1 - baseline / 2.0 else: offsety = ymin1