【问题标题】:Seaborn density plot hides scatter plotSeaborn 密度图隐藏散点图
【发布时间】:2020-01-08 16:10:09
【问题描述】:

我想用 seaborn 制作一个密度图,并在该散点图上绘制数据,但密度图隐藏了散点图的点。我怎样才能实现这些点在密度图上?

#!/usr/bin/env python3

import seaborn as sns
import matplotlib.pyplot as plt

df = sns.load_dataset('iris')

fig = plt.figure() 
ax = fig.add_subplot(111)

sns.kdeplot(df['sepal_width'], df['sepal_length'], ax = ax, bw = 0.4, cmap = 'Reds')
ax.scatter(df['sepal_width'], df['sepal_length'], s = 10)

fig.savefig('plot.pdf', bbox_inches='tight', dpi = 300)

【问题讨论】:

    标签: python matplotlib plot seaborn


    【解决方案1】:

    试试:

    
    ax.scatter(df['sepal_width'], df['sepal_length'], s = 10, zorder=2)
    
    

    【讨论】:

      猜你喜欢
      • 2020-12-04
      • 2019-09-14
      • 2020-07-28
      • 1970-01-01
      • 2017-05-09
      • 2019-09-26
      • 2019-04-15
      • 2020-10-07
      • 2020-11-07
      相关资源
      最近更新 更多