如何在Python中从数据框制作正态分布图?
我的问题是如何从Python中的数据框制作正态分布图。我可以找到很多信息来从随机数制作这样的图表,但我不知道如何从数据框制作它。
首先,我生成了随机数并制作了一个数据框。
import numpy as np
import pandas
from pandas import DataFrame
cv1 = np.random.normal(50, 3, 1000)
source = {"Genotype": ["CV1"]*1000, "AGW": cv1}
Cultivar_1=DataFrame(source)
然后,我尝试制作正态分布图。
sns.kdeplot(data = Cultivar_1['AGW'])
plt.xlim([30,70])
plt.xlabel("Grain weight (mg)", size=12)
plt.ylabel("Frequency", size=12)
plt.grid(True, alpha=0.3, linestyle="--")
plt.show()
但是,这是密度图,而不是使用均值和标准差计算的正态分布图。
你能告诉我需要使用哪些代码来制作正态分布图吗?
谢谢!!
my question is how to make a normal distribution graph from data frame in Python. I can find many information to make such a graph from random numbers, but I don't know how to make it from data frame.
First, I generated random numbers and made a data frame.
import numpy as np
import pandas
from pandas import DataFrame
cv1 = np.random.normal(50, 3, 1000)
source = {"Genotype": ["CV1"]*1000, "AGW": cv1}
Cultivar_1=DataFrame(source)
Then, I tried to make a normal distribution graph.
sns.kdeplot(data = Cultivar_1['AGW'])
plt.xlim([30,70])
plt.xlabel("Grain weight (mg)", size=12)
plt.ylabel("Frequency", size=12)
plt.grid(True, alpha=0.3, linestyle="--")
plt.show()
However, this is a density graph, not a normal distribution graph which is calculated using mean and standard deviation.
Could you let me know which codes I need to use to make a normal distribution graph?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是在 python 中从数据帧创建正态分布图的可能方法之一。
This is one of the possible way to create normal distribution graph from data frame in python.
我找到了一种从数据帧制作正态分布图的解决方案。
I found one solution to make a normal distribution graph from data frame.