matplotlib.pyplot.tick_params

matplotlib.pyplot.tick_params(axis='both', **kwargs) [source]

Change the appearance of ticks, tick labels, and gridlines.

Parameters:
axis{'x', 'y', 'both'}, optional

Which axis to apply the parameters to.

Other Parameters:
axis{'x', 'y', 'both'}

Axis on which to operate; default is 'both'.

resetbool, default: False

If True, set all parameters to defaults before processing other keyword arguments.

which{'major', 'minor', 'both'}

Default is 'major'; apply arguments to which ticks.

direction{'in', 'out', 'inout'}

Puts ticks inside the axes, outside the axes, or both.

lengthfloat

Tick length in points.

widthfloat

Tick width in points.

colorcolor

Tick color.

padfloat

Distance in points between tick and label.

labelsizefloat or str

Tick label font size in points or as a string (e.g., 'large').

labelcolorcolor

Tick label color.

colorscolor

Tick color and label color.

zorderfloat

Tick and label zorder.

bottom, top, left, rightbool

Whether to draw the respective ticks.

labelbottom, labeltop, labelleft, labelrightbool

Whether to draw the respective tick labels.

labelrotationfloat

Tick label rotation

grid_colorcolor

Gridline color.

grid_alphafloat

Transparency of gridlines: 0 (transparent) to 1 (opaque).

grid_linewidthfloat

Width of gridlines in points.

grid_linestylestr

Any valid Line2D line style spec.

Examples

Usage

ax.tick_params(direction='out', length=6, width=2, colors='r',
               grid_color='r', grid_alpha=0.5)

This will make all major ticks be red, pointing out of the box, and with dimensions 6 points by 2 points. Tick labels will also be red. Gridlines will be red and translucent.

© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.tick_params.html