publiplots.rotate

publiplots.rotate(ax, axis='x', rotation=45, ha=None, va=None)[source]

Rotate axis tick labels.

Commonly used when category labels are long or numerous.

Parameters:
  • ax (matplotlib.axes.Axes) – Axes to modify in place.

  • axis ({‘x’, ‘y’}, default 'x') – Which axis’s tick labels to rotate.

  • rotation (float, default 45) – Rotation angle in degrees, counter-clockwise.

  • ha ({'left', 'center', 'right'}, optional) – Horizontal alignment of tick labels. None leaves the existing alignment.

  • va ({'top', 'center', 'bottom', 'baseline'}, optional) – Vertical alignment of tick labels. None leaves the existing alignment.

Raises:

AssertionError – If axis is not 'x' or 'y'.

Examples

Rotate x-tick labels 45 degrees:

>>> pp.rotate(ax, axis='x', rotation=45)

Rotate y-tick labels 90 degrees with right-alignment:

>>> pp.rotate(ax, axis='y', rotation=90, ha='right')