The official website description is as follows:
Purpose of use: The kernel density estimation map is a visualization method, and the distribution of observations is locked in a data set, similar to a histogram. KDE represents data in one or more dimensions using continuous probability density curves.
Some parameters are as follows:
data | data, the input data structure. Collection of long-form vectors that can be assigned to named variables or wide-form datasets that will be reshaped internally. |
x, y | Variables specifying positions on the x and y axes. |
hue | Semantic variable mapped to determine the color of plot elements. |
weights | Weights, used to weight the kernel density estimate. |
palette | Palette, which can be a string, a list, or a dictionary, is used to draw colors for the graph. |
hue_order | Specify processing and plotting order for semantic taxonomy levels |
hue_norm | A pair of values that set the normalized range in data units or an object that will map from data units to the interval [0, 1]. |
color | Color, a single color specification when not using tonemapping. |
fill | fill, if True, fills in the area under the density curve in univariate or between contour lines in bivariate. Default if None. |
multiple | Semantic Map method for drawing multiple elements when creating subsets. Relevant only for univariate data. |
common_norm | If True, scales each conditional density by the number of observations such that the total area under all densities sums to 1. Otherwise, normalize each density individually. |
common_grid | If True, use the same evaluation grid for each kernel density estimate. Relevant only for univariate data. |
cumulative | boolean, optional If True, the cumulative distribution function is estimated. |
bw_method | string, method to determine the smoothing bandwidth to use |
bw_adjust | Numeric, using a factor that multiplicatively scales the selected value bw_method . Increasing it will make the curve smoother. See notes. |
warn_singular | Boolean, if True, warn when trying to estimate densities of data with zero variance. |
log_scale | a boolean or number, or a pair of booleans or numbers Set axis ticks to log. A single value sets the data axes for univariate distributions and both axes for bivariate distributions. A pair of values sets each axis independently. Numeric values are interpreted as the desired base (10 by default). If |
levels | int or vector, the number of contour levels or values at which to draw the contour. Vector arguments must have increasing values in [0, 1]. The levels correspond to the contours of the density: for example, there is a 20% probability that the mass will lie below the contour line drawn for 0.2. Only relevant for bivariate data. |
gridsize | Evaluate the number of points in each dimension of the grid. |
cut | The factor multiplied by the smoothing bandwidth determines how far the evaluation grid extends beyond extreme data points. When set to 0, the curve is truncated at the data limit. |
clip | Do not evaluate densities outside these limits. |
legend | Boolean, if False suppresses the legend for semantic variables. |
cbar_ax | A pre-existing axis for the colorbar. |
Taking the shared bicycle data table as an example, draw a kernel density estimation graph based on the data table:
As shown in the figure, two columns of temp (temperature) and windspeed (wind speed), two columns of temp (temperature) and humidity (humidity) are extracted, and the kernel density estimation map is drawn.
code:
fig,axes=plt.subplots(1,2,figsize=(12,6))
sns.kdeplot(data=data_2011,x='temp',y='windspeed',ax=axes[0],cmap='Greens',shade=True)
plt.subplots_adjust(wspace=0.2)
sns.kdeplot(data=data_2011,x='temp',y='humidity',ax=axes[1],cmap='Blues')
plt.show()