|
3 | 3 | ============================
|
4 | 4 |
|
5 | 5 | This module contains classes to support completely configurable tick
|
6 |
| -locating and formatting. Although the locators know nothing about major |
| 6 | +locating and formatting. Although the locators know nothing about major |
7 | 7 | or minor ticks, they are used by the Axis class to support major and
|
8 |
| -minor tick locating and formatting. Generic tick locators and |
| 8 | +minor tick locating and formatting. Generic tick locators and |
9 | 9 | formatters are provided, as well as domain specific custom ones.
|
10 | 10 |
|
11 | 11 | Default Formatter
|
12 | 12 | -----------------
|
13 | 13 |
|
14 |
| -The default formatter identifies when the x-data being |
15 |
| -plotted is a small range on top of a large off set. To |
16 |
| -reduce the chances that the ticklabels overlap the ticks |
17 |
| -are labeled as deltas from a fixed offset. For example:: |
| 14 | +The default formatter identifies when the x-data being plotted is a |
| 15 | +small range on top of a large off set. To reduce the chances that the |
| 16 | +ticklabels overlap the ticks are labeled as deltas from a fixed offset. |
| 17 | +For example:: |
18 | 18 |
|
19 | 19 | ax.plot(np.arange(2000, 2010), range(10))
|
20 | 20 |
|
21 |
| -will have tick of 0-9 with an offset of +2e3. If this |
22 |
| -is not desired turn off the use of the offset on the default |
23 |
| -formatter:: |
| 21 | +will have tick of 0-9 with an offset of +2e3. If this is not desired |
| 22 | +turn off the use of the offset on the default formatter:: |
24 | 23 |
|
25 | 24 | ax.get_xaxis().get_major_formatter().set_useOffset(False)
|
26 | 25 |
|
|
30 | 29 | Tick locating
|
31 | 30 | -------------
|
32 | 31 |
|
33 |
| -The Locator class is the base class for all tick locators. The locators |
| 32 | +The Locator class is the base class for all tick locators. The locators |
34 | 33 | handle autoscaling of the view limits based on the data limits, and the
|
35 |
| -choosing of tick locations. A useful semi-automatic tick locator is |
36 |
| -MultipleLocator. You initialize this with a base, e.g., 10, and it |
37 |
| -picks axis limits and ticks that are multiples of your base. |
| 34 | +choosing of tick locations. A useful semi-automatic tick locator is |
| 35 | +`MultipleLocator`. It is initialized with a base, e.g., 10, and it picks |
| 36 | +axis limits and ticks that are multiples of that base. |
38 | 37 |
|
39 | 38 | The Locator subclasses defined here are
|
40 | 39 |
|
|
59 | 58 | inside the limits
|
60 | 59 |
|
61 | 60 | :class:`MultipleLocator`
|
62 |
| - ticks and range are a multiple of base; |
63 |
| - either integer or float |
| 61 | + ticks and range are a multiple of base; either integer or float |
| 62 | +
|
64 | 63 | :class:`OldAutoLocator`
|
65 | 64 | choose a MultipleLocator and dyamically reassign it for
|
66 | 65 | intelligent ticking during navigation
|
|
74 | 73 |
|
75 | 74 | :class:`AutoMinorLocator`
|
76 | 75 | locator for minor ticks when the axis is linear and the
|
77 |
| - major ticks are uniformly spaced. It subdivides the major |
| 76 | + major ticks are uniformly spaced. It subdivides the major |
78 | 77 | tick interval into a specified number of minor intervals,
|
79 | 78 | defaulting to 4 or 5 depending on the major interval.
|
80 | 79 |
|
|
85 | 84 | There are a number of locators specialized for date locations - see
|
86 | 85 | the dates module
|
87 | 86 |
|
88 |
| -You can define your own locator by deriving from Locator. You must |
89 |
| -override the __call__ method, which returns a sequence of locations, |
| 87 | +You can define your own locator by deriving from Locator. You must |
| 88 | +override the ``__call__`` method, which returns a sequence of locations, |
90 | 89 | and you will probably want to override the autoscale method to set the
|
91 | 90 | view limits from the data limits.
|
92 | 91 |
|
93 | 92 | If you want to override the default locator, use one of the above or a
|
94 |
| -custom locator and pass it to the x or y axis instance. The relevant |
| 93 | +custom locator and pass it to the x or y axis instance. The relevant |
95 | 94 | methods are::
|
96 | 95 |
|
97 | 96 | ax.xaxis.set_major_locator( xmajorLocator )
|
|
105 | 104 | Tick formatting
|
106 | 105 | ---------------
|
107 | 106 |
|
108 |
| -Tick formatting is controlled by classes derived from Formatter. The |
| 107 | +Tick formatting is controlled by classes derived from Formatter. The |
109 | 108 | formatter operates on a single tick value and returns a string to the
|
110 | 109 | axis.
|
111 | 110 |
|
|
153 | 152 | Format labels as a percentage
|
154 | 153 |
|
155 | 154 | You can derive your own formatter from the Formatter base class by
|
156 |
| -simply overriding the ``__call__`` method. The formatter class has |
| 155 | +simply overriding the ``__call__`` method. The formatter class has |
157 | 156 | access to the axis view and data limits.
|
158 | 157 |
|
159 | 158 | To control the major and minor tick label formats, use one of the
|
|
165 | 164 | ax.yaxis.set_minor_formatter( yminorFormatter )
|
166 | 165 |
|
167 | 166 | See :ref:`pylab_examples-major_minor_demo1` for an example of setting
|
168 |
| -major and minor ticks. See the :mod:`matplotlib.dates` module for |
| 167 | +major and minor ticks. See the :mod:`matplotlib.dates` module for |
169 | 168 | more information and examples of using date locators and formatters.
|
170 | 169 | """
|
171 | 170 |
|
|
0 commit comments