mpl_toolkits.axisartist.axis_artist#
Theaxis_artist module implements custom artists to draw axis elements(axis lines and labels, tick lines and labels, grid lines).
Axis lines and labels and tick lines and labels are managed by theAxisArtistclass; grid lines are managed by theGridlinesCollection class.
There is oneAxisArtist per Axis; it can be accessed throughtheaxis dictionary of the parent Axes (which should be aAxes), e.g.ax.axis["bottom"].
Children of the AxisArtist are accessed as attributes:.line and.labelfor the axis line and label,.major_ticks,.major_ticklabels,.minor_ticks,.minor_ticklabels for the tick lines and labels (e.g.ax.axis["bottom"].line).
Children properties (colors, fonts, line widths, etc.) can be set usingsetters, e.g.
# Make the major ticks of the bottom axis red.ax.axis["bottom"].major_ticks.set_color("red")
However, things like the locations of ticks, and their ticklabels need to bechanged from the side of the grid_helper.
axis_direction#
AxisArtist,AxisLabel,TickLabels have anaxis_direction attribute,which adjusts the location, angle, etc. Theaxis_direction must be one of"left", "right", "bottom", "top", and follows the Matplotlib convention forrectangular axis.
For example, for thebottom axis (the left and right is relative to thedirection of the increasing coordinate),
ticklabels and axislabel are on the right
ticklabels and axislabel have text angle of 0
ticklabels are baseline, center-aligned
axislabel is top, center-aligned
The text angles are actually relative to (90 + angle of the direction to theticklabel), which gives 0 for bottom axis.
Property | left | bottom | right | top |
|---|---|---|---|---|
ticklabel location | left | right | right | left |
axislabel location | left | right | right | left |
ticklabel angle | 90 | 0 | -90 | 180 |
axislabel angle | 180 | 0 | 0 | 180 |
ticklabel va | center | baseline | center | baseline |
axislabel va | center | top | center | bottom |
ticklabel ha | right | center | right | center |
axislabel ha | right | center | right | center |
Ticks are by default direct opposite side of the ticklabels. To make ticks tothe same side of the ticklabels,
ax.axis["bottom"].major_ticks.set_tick_out(True)
The following attributes can be customized (use theset_xxx methods):
Ticks: ticksize, tick_outTickLabels: padAxisLabel: pad
Classes#
| An artist which draws axis (a line along which the n-th axes coord is constant) line, ticks, tick labels, and axis label. |
| Axis label. |
| Collection of grid lines. |
| A base class for |
| Tick labels. |
| Ticks are derived from |