Skip to content

Commit b9cc811

Browse files
committed
put in explicit field name for 2.6 compatibility.
1 parent fead68b commit b9cc811

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/matplotlib/tests/test_ticker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_formatstrformatter():
6464
nose.tools.assert_equal('00002', tmp_form(2))
6565

6666
# test str.format() style formatter
67-
tmp_form = mticker.StrMethodFormatter('{:05d}')
67+
tmp_form = mticker.StrMethodFormatter('{x:05d}')
6868
nose.tools.assert_equal('00002', tmp_form(2))
6969

7070

lib/matplotlib/ticker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ def __call__(self, x, pos=None):
305305
class StrMethodFormatter(Formatter):
306306
"""
307307
Use a new-style format string (as used by `str.format()`)
308-
to format the tick
308+
to format the tick. The field formatting must be labeled `x`.
309309
"""
310310
def __init__(self, fmt):
311311
self.fmt = fmt
312312

313313
def __call__(self, x, pos=None):
314314
'Return the format for tick val *x* at position *pos*'
315-
return self.fmt.format(x)
315+
return self.fmt.format(x=x)
316316

317317

318318
class OldScalarFormatter(Formatter):

0 commit comments

Comments
 (0)