matplotlib 纵坐标轴显示数据值

import matplotlib as mt
import numpy as np 
y=[7,0,0,0,0,0,1,25,98,333,471,0,322,429,425,478,385,237,219,284,351,364,165,0]
x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
x1=np.asanyarray(x)
y1=np.asanyarray(y)


import matplotlib.pyplot as plt 


fig=plt.figure()


ax1=fig.add_subplot(1,1,1)
ax1.bar(x1,y1)
ax1.yaxis.set_ticks(y1) #设置y轴刻度为y值

plt.show()


参考文献:matplotlib官网的docs

你可能感兴趣的:(python)