Home > OS >  Plotting a heatmap based on a scatterplot in Seaborn
Plotting a heatmap based on a scatterplot in Seaborn

Time:12-20

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.

enter image description here

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)

  • Related