8000 Merge pull request #21019 from anntzer/ct1 · timhoffm/matplotlib@39c5302 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39c5302

Browse files
authored
Merge pull request matplotlib#21019 from anntzer/ct1
2 parents 3d7a46e + 961a92c commit 39c5302

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

examples/ticks/custom_ticker1.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
"""
2-
==============
3-
Custom Ticker1
4-
==============
2+
=============
3+
Custom Ticker
4+
=============
55
6-
The new ticker code was designed to explicitly support user customized
7-
ticking. The documentation of :mod:`matplotlib.ticker` details this
8-
process. That code defines a lot of preset tickers but was primarily
9-
designed to be user extensible.
6+
The :mod:`matplotlib.ticker` module defines many preset tickers, but was
7+
primarily designed for extensibility, i.e., to support user customized ticking.
108
11-
In this example a user defined function is used to format the ticks in
9+
In this example, a user defined function is used to format the ticks in
1210
millions of dollars on the y axis.
1311
"""
14-
import matplotlib.pyplot as plt
1512

16-
money = [1.5e5, 2.5e6, 5.5e6, 2.0e7]
13+
import matplotlib.pyplot as plt
1714

1815

1916
def millions(x, pos):
2017
"""The two arguments are the value and tick position."""
2118
return '${:1.1f}M'.format(x*1e-6)
2219

20+
2321
fig, ax = plt.subplots()
24-
# Use automatic FuncFormatter creation
22+
# set_major_formatter internally creates a FuncFormatter from the callable.
2523
ax.yaxis.set_major_formatter(millions)
24+
money = [1.5e5, 2.5e6, 5.5e6, 2.0e7]
2625
ax.bar(['Bill', 'Fred', 'Mary', 'Sue'], money)
2726
plt.show()
2827

@@ -33,6 +32,4 @@ def millions(x, pos):
3332
# The use of the following functions, methods, classes and modules is shown
3433
# in this example:
3534
#
36-
# - `matplotlib.pyplot.subplots`
3735
# - `matplotlib.axis.Axis.set_major_formatter`
38-
# - `matplotlib.ticker.FuncFormatter`

0 commit comments

Comments
 (0)
0