diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 4c3c3e2d93e7..d4b37bee64ac 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -4,6 +4,7 @@ import six import numpy as np +from numpy.testing import assert_almost_equal import matplotlib from matplotlib.testing.decorators import image_comparison, knownfailureif, cleanup import matplotlib.pyplot as plt @@ -271,3 +272,9 @@ def test_get_rotation_raises(): def test_get_rotation_none(): from matplotlib import text assert text.get_rotation(None) == 0.0 + + +def test_get_rotation_mod360(): + from matplotlib import text + for i, j in zip([360., 377., 720+177.2], [0., 17., 177.2]): + assert_almost_equal(text.get_rotation(i), j) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 25ec28df53a0..b3b165e0495b 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -45,7 +45,8 @@ def _process_text_args(override, fontdict=None, **kwargs): # Extracted from Text's method to serve as a function def get_rotation(rotation): """ - Return the text angle as float. + Return the text angle as float. The returned + angle is between 0 and 360 deg. *rotation* may be 'horizontal', 'vertical', or a numeric value in degrees. """ @@ -62,7 +63,7 @@ def get_rotation(rotation): " 'vertical', numeric value or" "None".format(rotation)) - return angle + return angle % 360 # these are not available for the object inspector until after the # class is build so we define an initial set here for the init # function and they will be overridden after object defn