【问题标题】:Plotting a regression plot with a conditional Y axis绘制带有条件 Y 轴的回归图
【发布时间】:2021-01-04 22:05:00
【问题描述】:
sns.regplot(x='rows', y='credit_scores', data=df1)

我目前有此代码,以便用我的数据绘制一条回归线,其中 Y 轴“credit_scores”的范围为 0 - 250。但是,我的 4 个图是异常值,我不想包含在这个图中。这些异常值从 Y 轴上的 75 开始。所以,有什么办法让我设置一个条件,Y轴只选择75以下的所有数据值?

还有一种方法可以更改回归线的颜色,使其与我当前的蓝色图颜色不同。所以也许我的地块是蓝色的,回归线是红色的。

非常感谢!

【问题讨论】:

    标签: python pandas math regression scatter


    【解决方案1】:
    new_df1 = df1[df1['credit_scores'] < 75]
    sns.regplot(x='rows', y='credit_scores', data= new_df1 , color="red")
    
    

    此代码应该可以完成您的工作。 检查:

    Selecting rows based on conditions

    Regplot Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-06
      • 2019-02-19
      • 1970-01-01
      • 2010-12-15
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2018-02-08
      相关资源
      最近更新 更多