@header@
matplotlib.ticker | index /usr/local/lib/python2.3/site-packages/matplotlib/ticker.py |
Tick locating and formatting
============================
This module contains classes to support completely configurable tick
locating and formatting. Although the locators know nothing about
major or minor ticks, they are used by the Axis class to support major
and minor tick locating and formatting. Generic tick locators and
formatters are provided, as well as domain specific custom locators an
formatters.
Tick locating
-------------
The Locator class is the base class for all tick locators. The
locators handle autoscaling of the view limits based on the data
limits, and choosing the tick locations. The most generally useful
tick locator is MultipleLocator. You initialize this with a base, eg
10, and it picks axis limits and ticks that are multiples of your
base. The class AutoLocator contains a MultipleLocator instance, and
dynamically updates it based upon the data and zoom limits. This
should provide much more intelligent automatic tick locations both in
figure creation and in navigation than in prior versions of
matplotlib.
The basic generic locators are
* NullLocator - No ticks
* IndexLocator - locator for index plots (eg where x = range(len(y))
* LinearLocator - evenly spaced ticks from min to max
* LogLocator - logarithmically ticks from min to max
* MultipleLocator - ticks and range are a multiple of base;
either integer or float
* AutoLocator - choose a MultipleLocator and dyamically reassign
it for intelligent ticking during navigation
There are a number of locators specialized for date locations
* MinuteLocator - locate minutes that are a multiple of base
* HourLocator - locate hours that are a multiple of base
* DayLocator - locate a given hour each day
* DayMultiLocator - Make ticks on day which are multiples of base
* WeekdayLocator - locate a given weekday each week
* MonthLocator - locate months that are multiples of base
* YearLocator - locate years that are multiples of base
You can define your own locator by deriving from Locator. You must
override the __call__ method, which returns a sequence of locations,
and you will probably want to override the autoscale method to set the
view limits from the data limits.
If you want to override the default locator, use one of the above or a
custom locator and pass it to the x or y axis instance. The relevant
methods are::
ax.xaxis.set_major_locator( xmajorLocator )
ax.xaxis.set_minor_locator( xminorLocator )
ax.yaxis.set_major_locator( ymajorLocator )
ax.yaxis.set_minor_locator( yminorLocator )
The default minor locator is the NullLocator, eg no minor ticks on by
default.
Tick formatting
---------------
Tick formatting is controlled by classes derived from Formatter. The
formatter operates on a single tick value and returns a string to the
axis.
* NullFormatter - no labels on the ticks
* FixedFormatter - set the strings manually for the labels
* FuncFormatter - user defined function sets the labels
* FormatStrFormatter - use a sprintf format string
* IndexFormatter - cycle through fixed strings by tick position
* ScalarFormatter - default formatter for scalars; autopick the fmt string
* LogFormatter - formatter for log axes
* DateFormatter - use an strftime string to format the date
You can derive your own formatter from the Formatter base class by
simply overriding the __call__ method. The formatter class has access
to the axis view and data limits.
To control the major and minor tick label formats, use one of the
following methods::
ax.xaxis.set_major_formatter( xmajorFormatter )
ax.xaxis.set_minor_formatter( xminorFormatter )
ax.yaxis.set_major_formatter( ymajorFormatter )
ax.yaxis.set_minor_formatter( yminorFormatter )
See examples/major_minor_demo1.py for an example of setting major an
minor ticks. See the matplotlib.dates module for more information and
examples of using date locators and formatters.
DEVELOPERS NOTE
If you are implementing your own class or modifying one of these, it
is critical that you use viewlim and dataInterval READ ONLY MODE so
multiple axes can share the same locator w/o side effects!
Modules | ||||||
|
Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Functions | ||
|
Data | ||
Float = 'd' SEC_PER_DAY = 86400 SEC_PER_HOUR = 3600 SEC_PER_MIN = 60 SEC_PER_WEEK = 604800 division = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) log10 = <ufunc 'log10'> logical_and = <ufunc 'logical_and'> |