In a scatter plot I would like to create the effect of overlapping points. A sort of density gradient, as you can see in this picture:
I would like to do the same thing with the matplotlib. I tried with the alpha
parameter, as you can see in Fig2, but the effect does not come in the same way. In addition I would like to create an effect where for higher densities we go towards the black color, as in Fig1. Any ideas?
This is the code:
import matplotlib.pyplot as plt
import numpy as np
cat = np.genfromtxt('cat.txt')
x = np.array(cat[:,3])
y = np.array(cat[:,9])
fig, ax = plt.subplots(1,1)
ax.scatter(x,y, marker='.',zorder=3,alpha=0.2,c='r')
ax.grid(ls=':',zorder=0)