python

超轻量级php框架startmvc

matplotlib 纵坐标轴显示数据值的实例

更新时间:2020-06-03 18:42:01 作者:startmvc
实例如下所示:importmatplotlibasmtimportnumpyasnpy=[7,0,0,0,0,0,1,25,98,333,471,0,322,429,425,478,385,237,219,284

实例如下所示:


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

以上这篇matplotlib 纵坐标轴显示数据值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

matplotlib 坐标轴