Skip to content

Commit 1822356

Browse files
committed
Merge pull request #2746 from tacaswell/annotate_warning
ENH : added warning on annotate
2 parents 4507c9b + 6411d03 commit 1822356

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

lib/matplotlib/tests/test_coding_standards.py

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
'*/matplotlib/rcsetup.py',
6565
'*/matplotlib/stackplot.py',
6666
'*/matplotlib/texmanager.py',
67-
'*/matplotlib/text.py',
6867
'*/matplotlib/transforms.py',
6968
'*/matplotlib/type1font.py',
7069
'*/matplotlib/widgets.py',

lib/matplotlib/text.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from six.moves import zip
99

1010
import math
11+
import warnings
1112

1213
import numpy as np
1314

@@ -358,7 +359,7 @@ def _get_layout(self, renderer):
358359
cornersHoriz = np.array(
359360
[(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)],
360361
np.float_)
361-
cornersHoriz[:,1] -= descent
362+
cornersHoriz[:, 1] -= descent
362363

363364
# now rotate the bbox
364365
cornersRotated = M.transform(cornersHoriz)
@@ -574,7 +575,6 @@ def draw(self, renderer):
574575
renderer = PathEffectRenderer(self.get_path_effects(),
575576
renderer)
576577

577-
578578
if rcParams['text.usetex']:
579579
renderer.draw_tex(gc, x, y, clean_line,
580580
self._fontproperties, angle, mtext=self)
@@ -1536,7 +1536,7 @@ def _get_ref_xy(self, renderer):
15361536
if isinstance(self.xycoords, tuple):
15371537
s1, s2 = self.xycoords
15381538
if ((is_string_like(s1) and s1.split()[0] == "offset") or
1539-
(is_string_like(s2) and s2.split()[0] == "offset")):
1539+
(is_string_like(s2) and s2.split()[0] == "offset")):
15401540
raise ValueError("xycoords should not be an offset coordinate")
15411541
x, y = self.xy
15421542
x1, y1 = self._get_xy(renderer, x, y, s1)
@@ -1631,22 +1631,26 @@ def draggable(self, state=None, use_blit=False):
16311631
return self._draggable
16321632

16331633
@property
1634-
@cbook.deprecated('1.4', message='Use `anncoords` instead', name='textcoords', alternative='anncoords')
1634+
@cbook.deprecated('1.4', message='Use `anncoords` instead',
1635+
name='textcoords', alternative='anncoords')
16351636
def textcoords(self):
16361637
return self.anncoords
16371638

16381639
@textcoords.setter
1639-
@cbook.deprecated('1.4', message='Use `anncoords` instead', name='textcoords', alternative='anncoords')
1640+
@cbook.deprecated('1.4', message='Use `anncoords` instead',
1641+
name='textcoords', alternative='anncoords')
16401642
def textcoords(self, val):
16411643
self.anncoords = val
16421644

16431645
@property
1644-
@cbook.deprecated('1.4', message='Use `xyann` instead', name='xytext', alternative='xyann')
1646+
@cbook.deprecated('1.4', message='Use `xyann` instead',
1647+
name='xytext', alternative='xyann')
16451648
def xytext(self):
16461649
self.xyann
16471650

16481651
@xytext.setter
1649-
@cbook.deprecated('1.4', message='Use `xyann` instead', name='xytext', alternative='xyann')
1652+
@cbook.deprecated('1.4', message='Use `xyann` instead',
1653+
name='xytext', alternative='xyann')
16501654
def xytext(self, val):
16511655
self.xyann = val
16521656

@@ -1776,6 +1780,13 @@ def __init__(self, s, xy,
17761780
xy,
17771781
xycoords=xycoords,
17781782
annotation_clip=annotation_clip)
1783+
# warn about wonky input data
1784+
if (xytext is None and
1785+
textcoords is not None and
1786+
textcoords != xycoords):
1787+
warnings.warn("You have used the `textcoords` kwarg, but not "
1788+
"the `xytext` kwarg. This can lead to surprising "
1789+
"results.")
17791790

17801791
# clean up textcoords and assign default
17811792
if textcoords is None:

0 commit comments

Comments
 (0)