[英]How to plot Gaussian shaped histogram in python?
I have a df
named s
with just one column: 我有一个名为
s
的df
只有一列:
size
20
28
38
42
42
42
44
124
176
192
194
216
228
316
318
2048
2714
2802
4128
4186
6910
9313
10816
16560
20704
34766
91022
and I am plotting a histogram for the same using 我正在使用相同的直方图
sns.distplot(s['size'], bins = len(s))
and it yields a result as follows: 它产生如下结果:
I would like to know how can I make a few changes: 我想知道如何进行一些更改:
I would like to know how can these 2 tasks be achieved. 我想知道如何实现这两项任务。
Thanks 谢谢
You're going to struggle getting the "Guassian look" you want given that this data is not normally distributed. 鉴于此数据不是正常分布的,您将很难获得您想要的“高斯外观”。
Using the size
column as counts is the closest you'd be able to get to the "Guassian look" you linked (if this is at all how your data can be interpreted). 使用
size
列作为计数是您最接近您链接的“Guassian外观”(如果这完全是您的数据如何解释)。
import matplotlib.pyplot as plt
from io import StringIO
import pandas as pd
plt.style.use('seaborn')
data = pd.read_fwf(StringIO("""
20
28
38
42
42
42
44
124
176
192
194
216
228
316
318
2048
2714
2802
4128
4186
6910
9313
10816
16560
20704
34766
91022
"""), names=['size'], header=None)
plt.bar(range(data['size'].size), data['size'], width=1)
plt.xlabel('bin')
plt.ylabel('size')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.