- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
seaborn.histplot
生成的直方图和 seaborn.displot
不匹配。
sns.displot
的默认绘图是 kind='hist'
python3.8.11
、seaborn 0.11.2
和 matplotlib 3.4.2
测试bins
,相应地 block 的 density
应该匹配。
bins
被传递给 numpy.histogram_bin_edges
import seaborn as sns
import matplotlib.pyplot as plt
# sample data: wide
dfw = sns.load_dataset("penguins", cache=False)[['bill_length_mm', 'bill_depth_mm']].dropna()
# sample data: long
dfl = dfw.melt(var_name='bill_size', value_name='vals')
seaborn.displot
'sharex': False
,尽管 'sharey'
有效bins
fg = sns.displot(data=dfl, x='vals', col='bill_size', kde=True, stat='density', bins=12, height=4, facet_kws={'sharey': False, 'sharex': False})
plt.show()
xlim
没有什么不同fg = sns.displot(data=dfl, x='vals', col='bill_size', kde=True, stat='density', bins=12, height=4, facet_kws={'sharey': False, 'sharex': False})
axes = fg.axes.ravel()
axes[0].set_xlim(25, 65)
axes[1].set_xlim(13, 26)
plt.show()
seaborn.histplot
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
sns.histplot(data=dfw.bill_length_mm, kde=True, stat='density', bins=12, ax=ax1)
sns.histplot(data=dfw.bill_depth_mm, kde=True, stat='density', bins=12, ax=ax2)
fig.tight_layout()
plt.show()
common_bins=False
将直方图变成相同的形状,解决了忽略 bins
和 sharex
的问题。但是,密度
似乎受displot
中绘图数量的影响。
displot
中有 3 个图,则密度为 histplot
中显示的密度的 1/3;对于 2 个地 block ,密度为 1/2。最佳答案
common_bins=False
将直方图设置为相同的形状,解决了忽略 bins
和 sharex
的问题,以及 多面图中的密度
按每个方面中数据点的数量而不是方面的数量进行缩放。common_norm=False
解决了 displot
中 density
按绘图数量分割的问题# displot
fg = sns.displot(data=dfl, x='vals', col='bill_size', kde=True, stat='density', bins=12, height=4,
facet_kws={'sharey': False, 'sharex': False}, common_bins=False, common_norm=False)
fg.fig.subplots_adjust(top=0.85)
fg.fig.suptitle('Displot with common_bins & common_norm as False')
plt.show()
# histplot
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
sns.histplot(data=dfw.bill_length_mm, kde=True, stat='density', bins=12, ax=ax1)
sns.histplot(data=dfw.bill_depth_mm, kde=True, stat='density', bins=12, ax=ax2)
fig.subplots_adjust(top=0.85)
fig.suptitle('Histplot')
fig.tight_layout()
plt.show()
关于python-3.x - seaborn histplot 和 displot 输出不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68865538/
我的目标是将 Seaborn 显示插入单独的子图中。使用下面,我想将 Label1 传递给 ax1 并将 Label2 传递给 df2。但是,我收到警告:UserWarning: displot is
我正在尝试与此代码并排绘制两个缺陷 fig,(ax1,ax2) = plt.subplots(1,2) sns.displot(x =X_train['Age'], hue=y_train, ax=a
seaborn.kdeplot 的每个 hue 组如何? , 或 seaborn.displot与 kind='kde' 被赋予不同的 linestyle? 轴级和图形级选项都将接受 linestyl
我正在使用 seaborn 绘制分布图。我想用不同的颜色在同一个图上绘制多个分布: 这是我开始分布图的方式: import numpy as np import pandas as pd from s
我搜索了很多制作以刻度线为中心的直方图的方法,但无法找到适用于 seaborn displot 的解决方案。函数 displot 让我可以根据数据框中的列堆叠直方图,因此我更喜欢使用 displot
我正在尝试使用绘图函数中的内置 row/col 参数制作一个由 seaborn displots 组成的网格。 但是,我的某些行和列的值差异很大,默认情况下共享一个 x/y轴。 我需要弄清楚该放在哪里
seaborn.histplot 生成的直方图和 seaborn.displot不匹配。 sns.displot 的默认绘图是 kind='hist' 使用 python3.8.11、seaborn
我想在同一个图中用不同的颜色绘制直方图和 kde 线。我想为直方图设置绿色,为 kde 线设置蓝色。我设法弄清楚使用 line_kws 来更改 kde 线条颜色,但 hist_kws 不适用于 dis
根据 seaborn 文档 here seaborn.distplot()已被弃用,向前支持的图是:seaborn.displot()和 seaborn.histplot() . 但是,当我尝试使用
我是一名优秀的程序员,十分优秀!