Is there any way that I can plot a heatmap in seaborn based on a scatter plot? For instance, I have the following scatter plot and want to plot the corresponding heatmap in such a way that darker spots in the heatmap shows more crowded areas in the scatter plot.
CodePudding user response:
You can have one more variable which keeps track of number of points in its vicinity. And then use that variable ad colour in scatter plot.
CodePudding user response:
matplotlib.pyplot.hist2d
will accomplish this in "regular" matplotlib. It looks like seaborn.histplot
can do this as well (scroll down through the examples, it talks about making bivariate histograms when x
and y
arguments are specified)