Skip to content

Commit

Permalink
Merge pull request matplotlib#11000 from jklymak/fix-repr-text
Browse files Browse the repository at this point in the history
FIX: improve Text repr to not error if non-float x and y.
  • Loading branch information
tacaswell authored Apr 9, 2018
2 parents 4966c3f + 0089509 commit adaa8e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,10 @@ def test_text_as_text_opacity():
plt.text(0.25, 0.5, '50% using `alpha`', alpha=0.5)
plt.text(0.25, 0.75, '50% using `alpha` and 100% `color`', alpha=0.5,
color=(0, 0, 0, 1))


def test_text_repr():
# smoketest to make sure text repr doesn't error for category
plt.plot(['A', 'B'], [1, 2])
txt = plt.text(['A'], 0.5, 'Boo')
print(txt)
2 changes: 1 addition & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Text(Artist):
_cached = cbook.maxdict(50)

def __repr__(self):
return "Text(%g,%g,%s)" % (self._x, self._y, repr(self._text))
return "Text(%s, %s, %s)" % (self._x, self._y, repr(self._text))

def __init__(self,
x=0, y=0, text='',
Expand Down

0 comments on commit adaa8e5

Please sign in to comment.