python - Seaborn 密度图隐藏散点图
问题描述
我想用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)
推荐阅读
- react-native - 反应原生地图标记自定义图像不能从默认更改
- java - Java:如何将 int 添加到字母数字字符串中的数字并返回输出
- reactjs - reactJS store 中的对象数组实现
- react-native - 如何修复错误元素类型无效预期字符串?
- python - 渲染在 vtkCommand 中创建的演员(回调)
- ajax - 将 HTML 字符串传递给我的控制器操作方法
- bash - 如何使用tail和grep并获取具有结果的文件名
- javascript - 单选按钮值正在打印“on”而不是它持有的值
- c++ - 这是缓存线程安全的通用实现(c++)吗?
- java - 带有 ASM 的 JVM INVOKESPECIAL 私有构造函数