[英]Seaborn density plot hides scatter plot
I want to make a density plot with seaborn and over that scatter plot the data, but the density plot hides the points of the scatter plot.我想用seaborn制作一个密度图,并在该散点图上绘制数据,但密度图隐藏了散点图的点。 How can I achieve that the points are over the density plot?
我怎样才能实现点在密度图上?
#!/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.