我想用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)
尝试:
相关问题 更多 >
编程相关推荐