Scatterplot without linear fit in seaborn

前端 未结 3 1972
时光说笑
时光说笑 2021-02-07 00:34

I am wondering if there is a way to turn off the linear fit in seaborn\'s lmplot or if there is an equivalent function that just produces the scatterplot. Sure, I

相关标签:
3条回答
  • 2021-02-07 01:03

    set fit_reg argument to False:

    sns.lmplot("x", "y", data=df, hue='dataset', fit_reg=False)
    
    0 讨论(0)
  • 2021-02-07 01:17

    This doesn't directly answer the question, but may help others who find there way here who just want to do a plain old scatter plot.
    As of version 0.9.0 seaborn now has a scatterplot method.

    import seaborn as sns
    sns.set(style="ticks")
    
    df = sns.load_dataset("anscombe")
    sns.scatterplot("x", "y", data=df, hue='dataset')
    

    0 讨论(0)
  • 2021-02-07 01:18

    I recommend instead of sns.lmplot() to use sns.scatterplot()

    # import libaries
    import seaborn as sns
    
    # load tips dataset from GitHub seaborn repository
    tips_df = sns.load_dataset("tips")
    
    #create scatter plot
    sns.scatterplot(x = "tip", y = "total_bill", data = tips_df, hue ="sex")
    

    To learn more in detail follow seaborn scatter plot using sns.scatterplot() tutorial

    0 讨论(0)
提交回复
热议问题