0
votes

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. 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)
1

1 Answers

1
votes

Try:


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