You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1768+g23420a4c1
Fork me on GitHub

Related Topics

Rotating custom tick labelsΒΆ

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: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery