【发布时间】: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