How to increase/reduce the fontsize of x and y tick labels

You can set the fontsize directly in the call to set_xticklabels and set_yticklabels (as noted in previous answers). This will only affect one Axes at a time. ax.set_xticklabels(x_ticks, rotation=0, fontsize=8) ax.set_yticklabels(y_ticks, rotation=0, fontsize=8) Note this method should only be used if you are fixing the positions of the ticks first (e.g. using ax.set_xticks). If you … Read more

Show decimal places and scientific notation on the axis of a matplotlib plot

This is really easy to do if you use the matplotlib.ticker.FormatStrFormatter as opposed to the LogFormatter. The following code will label everything with the format ‘%.2e’: import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as mtick fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 300, 20) y = np.linspace(0,300, 20) y = … Read more