I have a histogram which is being generated from one of the dataframe column. But I want to make line similar to histogram.
I tried to extract histogram data & plot a line chart but didn’t worked.
data = [ 202.91, 236.04, 306.28, ... 315.83, 190.03 ] plt.hist(data) plt.show()
This code generate a histogram, but I need a line chart which shows the trend
Advertisement
Answer
This shows the step histogram line and a line plot on it passing from the center of each bin.
import numpy as np data = np.random.randn(1000) n, bins, patches = plt.hist(data, histtype=u'step') plt.plot(bins[:-1]+(bins[1]-bins[0])/2, n) plt.show()