@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
 
  * 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
 
  * 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
 
  * 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, data and display limits as attributes.
 
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, datalim and displaylim in READ ONLY
MODE so multiple axes can share the same locator w/o side effects!

 
Modules
       
math
os
re
sys
time

 
Classes
       
Base
Formatter
DateFormatter
FixedFormatter
FormatStrFormatter
FuncFormatter
NullFormatter
ScalarFormatter
LogFormatter
Locator
AutoLocator
FixedLocator
LinearLocator
LogLocator
MonthLocator
MultipleLocator
DayLocator
HourLocator
MinuteLocator
NullLocator
WeekdayLocator
YearLocator
Ticker
AutoTicker
LinearTicker
LogTicker
NullTicker

 
class AutoLocator(Locator)
    On autoscale this class picks the best MultipleLocator to set the
view limits and the tick locs.
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self)
autoscale(self)
Try to choose the view limits intelligently
get_locator(self, d)
pick the best locator based on a distance
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class AutoTicker(Ticker)
    best linear ticks
 
  Methods defined here:
__init__(self)

Methods inherited from Ticker:
get_labels(self)
get the tick labels as list of strings
get_locs(self)
get the locations of the ticks
get_numticks(self)
get the number of ticks
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Ticker:
formatter = <matplotlib.ticker.NullFormatter instance>
Always return the empty string
locator = <matplotlib.ticker.NullLocator instance>
No ticks

 
class Base
    this solution has some hacks to deal with floating point inaccuracies
 
  Methods defined here:
__init__(self, base)
ge(self, x)
return the largest multiple of base >= x
get_base(self)
gt(self, x)
return the largest multiple of base > x
le(self, x)
return the largest multiple of base <= x
lt(self, x)
return the largest multiple of base < x

 
class DateFormatter(Formatter)
    Tick location is seconds since the epoch.  Use a strftime format
string
 
  Methods defined here:
__call__(self, x, pos)
__init__(self, fmt)
fmt is an strftime format string

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class DayLocator(MultipleLocator)
    Make ticks at a given hour each day; default midnight
 
 
Method resolution order:
DayLocator
MultipleLocator
Locator

Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, hour=0)

Methods inherited from MultipleLocator:
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class FixedFormatter(Formatter)
    Return fixed strings for tick labels
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos
__init__(self, seq)
seq is a sequence of strings.  For positions i<len(seq) return
seq[i] regardless of x.  Otherwise return ''

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class FixedLocator(Locator)
    Tick locations are fixed
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, locs)

Methods inherited from Locator:
autoscale(self)
Try to choose the view limits intelligently
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class FormatStrFormatter(Formatter)
    Use a format string to format the tick
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos
__init__(self, fmt)

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class Formatter
    Convert the tick location to a string
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes defined here:
datalim = None
displaylim = None
viewlim = None

 
class FuncFormatter(Formatter)
    User defined function for formatting
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos
__init__(self, func)

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class HourLocator(MultipleLocator)
    Make ticks on hours which are multiples of base
 
 
Method resolution order:
HourLocator
MultipleLocator
Locator

Methods defined here:
__init__(self, base)

Methods inherited from MultipleLocator:
__call__(self)
Return the locations of the ticks
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class LinearLocator(Locator)
    Determine the tick locations
 
The first time this function is called it will try and set the
number of ticks to make a nice tick partitioning.  Thereafter the
number of ticks will be fixed so that interactive navigation will
be nice
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, numticks=None, presets=None)
Use presets to set locs based on lom.  A dict mapping vmin, vmax->locs
autoscale(self)
Try to choose the view limits intelligently

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class LinearTicker(Ticker)
    linear ticks
 
  Methods defined here:
__init__(self)

Methods inherited from Ticker:
get_labels(self)
get the tick labels as list of strings
get_locs(self)
get the locations of the ticks
get_numticks(self)
get the number of ticks
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Ticker:
formatter = <matplotlib.ticker.NullFormatter instance>
Always return the empty string
locator = <matplotlib.ticker.NullLocator instance>
No ticks

 
class Locator
    Determine the tick locations
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
autoscale(self)
Try to choose the view limits intelligently
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes defined here:
datalim = None
displaylim = None
viewlim = None

 
class LogFormatter(ScalarFormatter)
    Format values for log axis; only label decades
 
 
Method resolution order:
LogFormatter
ScalarFormatter
Formatter

Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos

Methods inherited from ScalarFormatter:
pprint_val(self, x, d)

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class LogLocator(Locator)
    Determine the tick locations for log axes
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
autoscale(self)
Try to choose the view limits intelligently

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class LogTicker(Ticker)
    log ticks
 
  Methods defined here:
__init__(self)

Methods inherited from Ticker:
get_labels(self)
get the tick labels as list of strings
get_locs(self)
get the locations of the ticks
get_numticks(self)
get the number of ticks
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Ticker:
formatter = <matplotlib.ticker.NullFormatter instance>
Always return the empty string
locator = <matplotlib.ticker.NullLocator instance>
No ticks

 
class MinuteLocator(MultipleLocator)
    Make ticks on minutes which are multiples of base
 
 
Method resolution order:
MinuteLocator
MultipleLocator
Locator

Methods defined here:
__init__(self, base)

Methods inherited from MultipleLocator:
__call__(self)
Return the locations of the ticks
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class MonthLocator(Locator)
    Make ticks on jan 1st of each year that is a multiple of base
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, base=1)
mark years that are multiple of base
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Data and other attributes defined here:
epochConverter = <matplotlib.dates.EpochConverter instance>
Represent time in the epoch

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class MultipleLocator(Locator)
    Set a tick on every integer that is multiple of base in the
viewlim
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, base=1.0)
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class NullFormatter(Formatter)
    Always return the empty string
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class NullLocator(Locator)
    No ticks
 
  Methods defined here:
__call__(self)
Return the locations of the ticks

Methods inherited from Locator:
autoscale(self)
Try to choose the view limits intelligently
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class NullTicker(Ticker)
    no ticks
 
  Methods defined here:
__init__(self)

Methods inherited from Ticker:
get_labels(self)
get the tick labels as list of strings
get_locs(self)
get the locations of the ticks
get_numticks(self)
get the number of ticks
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Ticker:
formatter = <matplotlib.ticker.NullFormatter instance>
Always return the empty string
locator = <matplotlib.ticker.NullLocator instance>
No ticks

 
class ScalarFormatter(Formatter)
    Tick location is a plain old number.  If viewlim is set, the
formatter will use %d, %1.#f or %1.ef as appropriate.  If it is
not set, the formatter will do str conversion
 
  Methods defined here:
__call__(self, x, pos)
Return the format for tick val x at position pos
pprint_val(self, x, d)

Methods inherited from Formatter:
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes inherited from Formatter:
datalim = None
displaylim = None
viewlim = None

 
class Ticker
     Methods defined here:
get_labels(self)
get the tick labels as list of strings
get_locs(self)
get the locations of the ticks
get_numticks(self)
get the number of ticks
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis

Data and other attributes defined here:
formatter = <matplotlib.ticker.NullFormatter instance>
Always return the empty string
locator = <matplotlib.ticker.NullLocator instance>
No ticks

 
class WeekdayLocator(Locator)
     Methods defined here:
__call__(self)
__init__(self, day)
Use ticks on weekdays that match day numbered from monday =0.
matplotlib.dates defines constants MONDAY thru SUNDAY
autoscale(self)
Set the view limits to the nearest days that are on the
specified day that contains the data
get_ticklocs(self)
return the tick locations in seconds since epoch

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
class YearLocator(Locator)
    Make ticks on jan 1st of each year that is a multiple of base
 
  Methods defined here:
__call__(self)
Return the locations of the ticks
__init__(self, base=1)
mark years that are multiple of base
autoscale(self)
Set the view limits to the nearest multiples of base that
contain the data

Data and other attributes defined here:
epochConverter = <matplotlib.dates.EpochConverter instance>
Represent time in the epoch

Methods inherited from Locator:
pan(self, numsteps)
Pan numticks (can be positive or negative)
set_lim(self, viewlim, datalim, displaylim)
set the view, data and display limits of the axis
zoom(self, direction)
Zoom in/out on axis; if direction is >0 zoom in, else zoom out

Data and other attributes inherited from Locator:
datalim = None
displaylim = None
viewlim = None

 
Functions
       
arange(...)
arange(start, stop=None, step=1, typecode=None)
 
 Just like range() except it returns an array whose type can be
specified by the keyword argument typecode.
array(...)
array(sequence, typecode=None, copy=1, savespace=0) will return a new array formed from the given (potentially nested) sequence with type given by typecode.  If no typecode is given, then the type will be determined as the minimum type required to hold the objects in sequence.  If copy is zero and sequence is already an array, a reference will be returned.  If savespace is nonzero, the new array will maintain its precision in operations.
closeto(x, y)
decade_down(x)
floor x to the nearest lower decade
decade_up(x)
ceil x to the nearest higher decade
take(...)
take(a, indices, axis=0).  Selects the elements in indices from array a along the given axis.
zeros(...)
zeros((d1,...,dn),typecode='l',savespace=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.  If savespace is nonzero the array will be a spacesaver array.

 
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'>
@footer@