diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index e6bef4d70134..aa1bbce54c2d 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -64,7 +64,6 @@ '*/matplotlib/rcsetup.py', '*/matplotlib/stackplot.py', '*/matplotlib/texmanager.py', - '*/matplotlib/text.py', '*/matplotlib/transforms.py', '*/matplotlib/type1font.py', '*/matplotlib/widgets.py', diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index ccdf93f36015..42fb58ab76ad 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -8,6 +8,7 @@ from six.moves import zip import math +import warnings import numpy as np @@ -358,7 +359,7 @@ def _get_layout(self, renderer): cornersHoriz = np.array( [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)], np.float_) - cornersHoriz[:,1] -= descent + cornersHoriz[:, 1] -= descent # now rotate the bbox cornersRotated = M.transform(cornersHoriz) @@ -574,7 +575,6 @@ def draw(self, renderer): renderer = PathEffectRenderer(self.get_path_effects(), renderer) - if rcParams['text.usetex']: renderer.draw_tex(gc, x, y, clean_line, self._fontproperties, angle, mtext=self) @@ -1536,7 +1536,7 @@ def _get_ref_xy(self, renderer): if isinstance(self.xycoords, tuple): s1, s2 = self.xycoords if ((is_string_like(s1) and s1.split()[0] == "offset") or - (is_string_like(s2) and s2.split()[0] == "offset")): + (is_string_like(s2) and s2.split()[0] == "offset")): raise ValueError("xycoords should not be an offset coordinate") x, y = self.xy x1, y1 = self._get_xy(renderer, x, y, s1) @@ -1631,22 +1631,26 @@ def draggable(self, state=None, use_blit=False): return self._draggable @property - @cbook.deprecated('1.4', message='Use `anncoords` instead', name='textcoords', alternative='anncoords') + @cbook.deprecated('1.4', message='Use `anncoords` instead', + name='textcoords', alternative='anncoords') def textcoords(self): return self.anncoords @textcoords.setter - @cbook.deprecated('1.4', message='Use `anncoords` instead', name='textcoords', alternative='anncoords') + @cbook.deprecated('1.4', message='Use `anncoords` instead', + name='textcoords', alternative='anncoords') def textcoords(self, val): self.anncoords = val @property - @cbook.deprecated('1.4', message='Use `xyann` instead', name='xytext', alternative='xyann') + @cbook.deprecated('1.4', message='Use `xyann` instead', + name='xytext', alternative='xyann') def xytext(self): self.xyann @xytext.setter - @cbook.deprecated('1.4', message='Use `xyann` instead', name='xytext', alternative='xyann') + @cbook.deprecated('1.4', message='Use `xyann` instead', + name='xytext', alternative='xyann') def xytext(self, val): self.xyann = val @@ -1776,6 +1780,13 @@ def __init__(self, s, xy, xy, xycoords=xycoords, annotation_clip=annotation_clip) + # warn about wonky input data + if (xytext is None and + textcoords is not None and + textcoords != xycoords): + warnings.warn("You have used the `textcoords` kwarg, but not " + "the `xytext` kwarg. This can lead to surprising " + "results.") # clean up textcoords and assign default if textcoords is None: