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

Skip to content

Commit 4633731

Browse files
committed
When text argument is needed, convert to text if necessary
svn path=/trunk/matplotlib/; revision=3089
1 parent dd4eca9 commit 4633731

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

API_CHANGES

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
Commands that pass an argument to the Text constructor or to
2+
Text.set_text() now accept any object that can be converted
3+
with '%s'. This affects xlabel(), title(), etc.
4+
15
Barh now takes a **kwargs dict instead of most of the old
26
arguments. This helps ensure that bar and barh are kept in sync,
37
but as a side effect you can no longer pass e.g. color as a
48
positional argument.
59

610
ft2font.get_charmap() now returns a dict that maps character codes
711
to glyph indices (until now it was reversed)
8-
12+
913
Moved data files into lib/matplotlib so that setuptools' develop
1014
mode works. Re-organized the mpl-data layout so that this source
1115
structure is maintained in the installation. (I.e. the 'fonts' and

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2007-03-17 Text.set_text() accepts anything convertible with '%s' - EF
2+
13
2007-03-14 Add masked-array support to hist. - EF
24

35
2007-03-03 Change barh to take a kwargs dict and pass it to bar.

lib/matplotlib/text.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ def __init__(self,
143143
"""
144144

145145
Artist.__init__(self)
146-
if not is_string_like(text):
147-
raise TypeError('text must be a string type')
148146
self.cached = maxdict(5)
149147
self._x, self._y = x, y
150148

@@ -729,11 +727,9 @@ def set_text(self, s):
729727
"""
730728
Set the text string s
731729
732-
ACCEPTS: string
730+
ACCEPTS: string or anything printable with '%s' conversion
733731
"""
734-
if not is_string_like(s):
735-
raise TypeError("This doesn't look like a string: '%s'"%s)
736-
self._text = s
732+
self._text = '%s' % (s,)
737733
#self._substrings = scanner(s) # support embedded mathtext
738734
self._substrings = [] # ignore embedded mathtext for now
739735

0 commit comments

Comments
 (0)