【问题标题】:distribution plot with seabornseaborn 分布图
【发布时间】:2021-04-27 14:31:10
【问题描述】:

我想绘制“新近度”变量的分布(见图),但我在 Y 轴上的值从 0,0000 到 0,0016。我想通过频率改变它们,使其更加清晰和不稳定。 有什么建议

# Distribution of recency, frequency, monetary
fig, ax = plt.subplots(3, 1, figsize = (10, 20))
for idx, val in enumerate(df_user.drop('COMPANY_CODE', axis = 1)):
      sns.distplot(df_user[val], ax = ax[idx], hist=True)

plt.tight_layout()

【问题讨论】:

  • histplot 有一个选项stat=,可以是“count”“frequency”“density”“probability”(Seaborn 版本 0.11.1)
  • 注意,如果你想显示kde curve,你会得到一个带有density的y轴

标签: plot seaborn


【解决方案1】:

试试log_scale=True

# Distribution of recency, frequency, monetary
fig, ax = plt.subplots(3, 1, figsize = (10, 20))
for idx, val in enumerate(df_user.drop('COMPANY_CODE', axis = 1)):
      sns.histplot(df_user[val], ax = ax[idx], hist=True, log_scale=True)

【讨论】:

  • 谢谢,但它不起作用,我收到此错误:TypeError: distplot() got an unexpected keyword argument 'log_scale'
  • 尝试使用 histplot 而不是 distplot
猜你喜欢
  • 1970-01-01
  • 2021-11-03
  • 1970-01-01
  • 2020-06-21
  • 2021-08-10
  • 2018-03-11
  • 2020-06-18
  • 2021-01-19
  • 2020-09-14
相关资源
最近更新 更多