实例如下所示:
import matplotlib as mtimport 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
以上这篇matplotlib 纵坐标轴显示数据值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林站长站。
新闻热点
疑难解答