Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added %s support for labels. #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated set_text docstring.
  • Loading branch information
pelson committed Aug 19, 2012
commit ff9c545ba1902b41d9965c270b65de68f6398576
2 changes: 1 addition & 1 deletion lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def set_label(self, s):
"""
Set the label to *s* for auto legend.

ACCEPTS: any string
ACCEPTS: string or anything printable with '%s' conversion.
"""
self._label = '%s' % (s, )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this equivalent to str(s)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently not (I always thought it was until this evening):

>>> a = u"Hello\u2026"
>>> str(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 5: ordinal not in range(128)
>>> '%s' % a
u'Hello\u2026'

self.pchanged()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_label(self, s):
"""
Set the label to *s* for auto legend.

ACCEPTS: any string
ACCEPTS: string or anything printable with '%s' conversion.
"""
self._label = '%s' % (s, )
self.pchanged()
Expand Down