Last active
March 13, 2019 05:57
-
-
Save BedirYilmaz/7e8ac6d93758462484e4dab15cdedabb to your computer and use it in GitHub Desktop.
Change x tick labels in pyplot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/a/11250884/776348 | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots() | |
# We need to draw the canvas, otherwise the labels won't be positioned and | |
# won't have values yet. | |
fig.canvas.draw() | |
labels = ['m','y','l','a','b','e','l','s'] | |
for label in ax.xaxis.get_ticklabels(): | |
# tick.label.set_fontsize(19) | |
# specify integer or one of preset strings, e.g. | |
label.set_fontsize('x-small') # tick label attributes | |
label.set_rotation('vertical') | |
ax.set_xticklabels(labels) # tick label content | |
plt.xticks(range(len(labels))) # tick positions to make sure you get them printed in right frequency | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment