Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib make tick labels font size smaller

In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller?

Further, how can one rotate it from horizontal to vertical?

like image 645
Open the way Avatar asked Jun 17 '11 18:06

Open the way


People also ask

How do I make the labels smaller in Matplotlib?

In current versions of Matplotlib, you can do axis. set_xticklabels(labels, fontsize='small') . That forces you to specify the labels too.

How do I change the font size axis labels in Matplotlib?

If we want to change the font size of the axis labels, we can use the parameter “fontsize” and set it your desired number.


1 Answers

There is a simpler way actually. I just found:

import matplotlib.pyplot as plt # We prepare the plot   fig, ax = plt.subplots()  # We change the fontsize of minor ticks label  ax.tick_params(axis='both', which='major', labelsize=10) ax.tick_params(axis='both', which='minor', labelsize=8) 

This only answers to the size of label part of your question though.

like image 159
Autiwa Avatar answered Sep 22 '22 20:09

Autiwa