The quickist way to show the density distribution of all dots would be using matplotlib directly.
from matplotlib.colors import LogNorm from matplotlib import pyplot as plt h =plt.hist2d(geyser.duration, geyser.waiting, bins= 30, norm=LogNorm(), cmap="coolwarm") plt.colorbar(h[3]) plt.show()
More fancy way
It would be take some time for fitting the gaussian kernel. But it still way fast than using Seaborn directly.
fig = plt.figure(figsize=(13, 7)) ax = plt.axes(projection='3d') surf = ax.plot_surface(xx, yy, f, rstride=1, cstride=1, cmap='coolwarm', edgecolor='none') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('PDF') ax.set_title('Surface plot of Gaussian 2D KDE') fig.colorbar(surf, shrink=0.5, aspect=5) # add color bar indicating the PDF ax.view_init(60, 35)
Something else
There is another exmple from stackoverflow by Flabetvibes, 2015. It works fine with the example data. But I just don’t know how to adjust the arguments for fit my data.
import numpy as np import matplotlib.pyplot as pl import scipy.stats as st
data = np.random.multivariate_normal((0, 0), [[0.8, 0.05], [0.05, 0.7]], 100)
x = data[:, 0] y = data[:, 1] xmin, xmax = -3, 3 ymin, ymax = -3, 3
# Peform the kernel density estimate xx, yy = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([xx.ravel(), yy.ravel()]) values = np.vstack([x, y]) kernel = st.gaussian_kde(values) f = np.reshape(kernel(positions).T, xx.shape)