I have data like [A,A,A,B,B,B,B,B,B,C,C,C,C,D,D,D,...]
And I convert it into numerical list like [1,1,1,2,2,2,2,2,2,3,3,3,3,4,4,4,...]
Each element has its frequency, for example, A shows up 3 times
I try to plot histogram and I get like this
Third element (probably C as character) shows up most often.
And I would like to place "third element vertical bar" in the center
And next to that center, I would like to place second and third frequent element to draw normal distribution-like arrangement.
In conclusion, I would like to see whether distribution of data has normal distribution shape or not I checked this by using QQ plot but I also would like to see this in histogram plot using actual data
If I understood well what your goal is, I would recommend you to use the distplot
function from seaborn. You will get both distribution and hist !
You have asked so many questions in a single post. I will answer the one regarding plotting frequency of occurrence. Suppose your list has strings. You can use Counter
module to compute the frequencies. You can then directly plot the frequencies and items using plt.plot()
from collections import Counter
import matplotlib.pyplot as plt
lst = ['A','A','A','B','B','B','B','B','B','C','C','C','C','D','D','D','E', 'E','E','E']
counts = Counter(lst)
plt.bar(counts.keys(), counts.values())
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.