繁体   English   中英

Seaborn 密度图隐藏散点图

[英]Seaborn density plot hides scatter plot

我想用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)

尝试:


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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM