I want to increase the font size of the yticklabels
and also want to make them bold. I am using a log scale for the Y-axis. I get only the first yticklabel in large size and others are small. Following is my code:
from matplotlib import pyplot as plt
import matplotlib.ticker
fig1, ax1 = plt.subplots(figsize=(10,6),dpi=100)
ax1.plot([10, 100, 1000], [1,2,3])
ax1.set_yscale('log')
ax1.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
ax1.tick_params(axis='y', labelsize=20)
plt.show()
Please help to solve the problem.
This is a strange behavior...
However, it is still possible to get the expected result by changing the ytick
configuration, in the beginning of the code, with this line:
matplotlib.rc('ytick', labelsize=20)
You may also change the color too for the labels:
matplotlib.rc('ytick', labelsize=20, labelcolor='red')
But, a change on font weight will apply to both axes, using the code:
matplotlib.rc('font', weight='bold')
There are more options listed on the official documentation:
https://matplotlib.org/stable/gallery/misc/customize_rc.html
https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rc
https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rcParams