Seaborn regplot with colorbar?

后端 未结 3 1842
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 17:06

I\'m plotting something with seaborn\'s regplot. As far as I understand, it uses pyplot.scatter behind the scenes. So I assumed that if I specify c

3条回答
  •  北海茫月
    2020-12-30 17:09

    Another approach would be

    import seaborn as sns
    import matplotlib.pyplot as plt
    
    tips = sns.load_dataset("tips")
    
    points = plt.scatter(tips["total_bill"], tips["tip"],
                         c=tips["size"], s=75, cmap="BuGn")
    plt.colorbar(points)
    
    sns.regplot("total_bill", "tip", data=tips, scatter=False, color=".1")
    

    enter image description here

提交回复
热议问题