Home > Mobile >  Change fontsize on y axis in barh plot from matplotlib
Change fontsize on y axis in barh plot from matplotlib

Time:01-10

I want to change the fontsize of the lable on the y axis of a horizontal barplot (i.e. make the fontsize of "Question 1", "Question 2" bigger). I could not find the solution from the enter image description here

CodePudding user response:

Use plt.yticks:

import matplotlib.pyplot as plt
import numpy as np
 
x = np.array(["Question 1", "Question 2", "Question 3", "Question 4"])
y = np.array([3, 8, 1, 10])
 
plt.barh(x, y)
plt.yticks(fontsize=20)
plt.tight_layout()
plt.show()

enter image description here

  •  Tags:  
  • Related