
Change the font size or font name (family) of ticks in Matplotlib
You can change the fontsize of x and y ticks in a bar chart by using xticks()
and yticks()
.
from matplotlib import pyplot
x = ['Fri', 'Sat', 'Sun']
y = [26, 31, 19]
pyplot.bar(x, y)
pyplot.xticks(fontsize=22)
pyplot.yticks(fontsize=45)
pyplot.savefig('fontsize.jpg')

Change the font family
Font family can be also changed by setting the fontname option.
from matplotlib import pyplot
x = ['Fri', 'Sat', 'Sun']
y = [26, 31, 19]
pyplot.bar(x, y)
pyplot.xticks(fontsize=22, fontname='Georgia')
pyplot.yticks(fontsize=45)
pyplot.savefig('fontname.jpg')

Change the color
from matplotlib import pyplot
x = ['Fri', 'Sat', 'Sun']
y = [26, 31, 19]
pyplot.plot(x, y)
pyplot.xticks(fontsize=16, fontname='Georgia')
pyplot.yticks(fontsize=20, color='#e63a2e')
pyplot.savefig('color.jpg')

Comments
Powered by Markdown