Plotting histogram as a line plot in matplot using x and y values ​​in python

I have two input values ​​for the X-axis and Y-axis. I would like to plot a histogram as a line graph. An example is shown in the attached image. I am unable to plot a histogram using these values.

ys = [0.21428571428571427, 0.14285714285714285, 0.047619047619047616, 0.11904761904761904, 0.09523809523809523, 0.09523809523809523, 0.023809523809523808, 0.09523809523809523, 0.11904761904761904, 0.047619047619047616]

xs = [0,1,2,3,4,5,6,7,8,9]

      

I tried

plt.hist(xs,ys)
plt.show()

      

but it failed.

I am interested in a graph similar to the following, preferably with and without a line on the histogram.

enter image description here...

The X and Y axis are assigned by the xs and ys values.

+3


source to share


1 answer


You need a function bar

. Here's a minimal example:

>>> bar(xs, ys, width=1, align='center', color='brown')
>>> plot(xs, ys, color='purple', lw=2, marker='s')

      



+5


source







All Articles