【问题标题】:python seaborn lmplot regplot for y-log scale fitpython seaborn lmplot regplot 用于 y-log 比例拟合
【发布时间】:2015-07-17 02:40:58
【问题描述】:

我想知道为什么 seaborn lmplot 和 regplot 只能选择执行 logx。我经常使用线性拟合 log(y) ~ x 并且 Y 轴应始终采用对数刻度以显示相关性(作为惯例)。

这是可以在 Seaborn 中完成的事情吗?

logy=True 的选项会很好...

谢谢。

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    您可以简单地设置 y 轴刻度来记录:

    import seaborn as sns; sns.set(color_codes=True)
    tips = sns.load_dataset("tips")
    ax = sns.regplot(x="total_bill", y="tip", data=tips)
    ax.set_yscale('log')  # set_yscale is a function, not a string
    

    【讨论】:

    • 使用 regplot 示例编辑的答案更加明确
    • 是否可以将 x 轴设为对数刻度?
    • 我不认为这是正确的,拟合仍然是线性的,对吧?只有轴会以对数刻度显示。
    【解决方案2】:

    你可以使用regplot返回的axis来做到这一点:

    ax = seaborn.regplot('x', 'y', data)
    ax.set(yscale='log')       
    

    【讨论】:

      猜你喜欢
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      • 2020-11-09
      • 2015-08-01
      • 1970-01-01
      • 2021-12-10
      相关资源
      最近更新 更多