You are reading an old version of the documentation (v1.5.0). For the latest version see

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

ticks_and_spines example code:

Next topic

units Examples

This Page

ticks_and_spines example code: ticklabels_demo_rotation.pyΒΆ

(Source code, png, hires.png, pdf)

Demo of custom tick-labels with user-defined rotation.
import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [1, 4, 9, 6]
labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']

plt.plot(x, y, 'ro')
# You can specify a rotation for the tick labels in degrees or with keywords.
plt.xticks(x, labels, rotation='vertical')
# Pad margins so that markers don't get clipped by the axes
# Tweak spacing to prevent clipping of tick-labels

Keywords: python, matplotlib, pylab, example, codex (see Search examples)