The matplotlib axis shows instances of data values

  • 2020-09-28 08:58:11
  • OfStack

Examples are as follows:


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) # Set up the y Axis calibration for y value 
plt.show()

References: docs on matplotlib


Related articles: