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

Skip to content

Commit f6b7189

Browse files
committed
DOC: show that FuncFormatter can be a decorator
1 parent c44556f commit f6b7189

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/ticks_and_spines/tick-formatters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def setup(ax):
5151
fontsize=15, transform=ax.transAxes)
5252

5353

54-
# Func formatter
54+
# FuncFormatter can be used as a decorator
55+
@ticker.FuncFormatter
5556
def major_formatter(x, pos):
5657
return "[%.2f]" % x
5758

@@ -60,7 +61,7 @@ def major_formatter(x, pos):
6061
setup(ax)
6162
ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00))
6263
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
63-
ax.xaxis.set_major_formatter(ticker.FuncFormatter(major_formatter))
64+
ax.xaxis.set_major_formatter(major_formatter)
6465
ax.text(0.0, 0.1, 'FuncFormatter(lambda x, pos: "[%.2f]" % x)',
6566
fontsize=15, transform=ax.transAxes)
6667

0 commit comments

Comments
 (0)