python - 修改正 x 的直方图曲线
问题描述
我有一些直方图代码如下:
plt.subplots(figsize=(10,8), dpi=100)
sns.distplot(x1, color='k', label='a',norm_hist = True)
sns.distplot(x2, color='g', label='b',norm_hist = True)
sns.distplot(x3, color='b', label='b',norm_hist = True)
sns.distplot(x4, color='r', label='c',norm_hist = True)
sns.distplot(x5, color='y', label='c',norm_hist = True)
这很好,但我真正想要的是仅在正 x 值上拟合曲线。负持续时间没有物理意义。有什么选择吗?
解决方案
从sns.distplot()
文档中:
...它还可以拟合 scipy.stats 分布并在数据上绘制估计的 PDF。
因此,您可以选择对您的数据有意义的非负分布,并使用fit
参数传递适合您数据的SciPy 分布对象。
例如:
import seaborn as sns
from scipy import stats
iris = sns.load_dataset('iris')
sns.distplot(iris.petal_length, color='k', fit=stats.expon, kde=False)
推荐阅读
- assembly - 在armV7中计算字符串中的字符
- r - 需要帮助在 ggplot2 中创建特定类型的同位素图
- excel - 多个命令按钮
- python - 如何使用 swagger/openapi 在客户端/服务器之间正确共享代码
- python - matplotlib.backends.backend_tkagg 为“blit”引发属性错误
- python - groupby 返回数据中不存在的键上的组
- ios - 使用 CGAffineTransform 缩放 tableView 单元格以覆盖整个屏幕
- scrapy - scrapyd在一秒钟后停止,日志文件中没有错误消息
- javascript - React Navigation 说渲染没有返回任何内容
- angular - 如何更新 Observable 返回的许多对象的新属性?