Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit adaa8e5

Browse filesBrowse files
authored
Merge pull request #11000 from jklymak/fix-repr-text
FIX: improve Text repr to not error if non-float x and y.
2 parents 4966c3f + 0089509 commit adaa8e5
Copy full SHA for adaa8e5

File tree

Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed

‎lib/matplotlib/tests/test_text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_text.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,10 @@ def test_text_as_text_opacity():
496496
plt.text(0.25, 0.5, '50% using `alpha`', alpha=0.5)
497497
plt.text(0.25, 0.75, '50% using `alpha` and 100% `color`', alpha=0.5,
498498
color=(0, 0, 0, 1))
499+
500+
501+
def test_text_repr():
502+
# smoketest to make sure text repr doesn't error for category
503+
plt.plot(['A', 'B'], [1, 2])
504+
txt = plt.text(['A'], 0.5, 'Boo')
505+
print(txt)

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Text(Artist):
132132
_cached = cbook.maxdict(50)
133133

134134
def __repr__(self):
135-
return "Text(%g,%g,%s)" % (self._x, self._y, repr(self._text))
135+
return "Text(%s, %s, %s)" % (self._x, self._y, repr(self._text))
136136

137137
def __init__(self,
138138
x=0, y=0, text='',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.