# 17.2.7 Creating 2D Kernel Density Plot

The 2D Kernel Density plot is a smoothed color density representation of the scatterplot, based on kernel density estimation, a nonparametric technique for probability density functions. The goal of density estimation is to take a finite sample of data and to infer the underyling probability density function everywhere, including where no data point are presented. In kernel density estimation, the contribution of each data point is smoothed out from a single point into a region of vicinity. These smoothed density plot shows an average trend for the scatter plot.

Origin supports two methods to calculate the density plot Bivariate Kernel Density Estimator and Rules of Thumb. You can refer to ks2density function for more details about the algorithm.

## Creating 2D Kernel Density Plot

To create a 2D Kernel Density plot:

1. Highlight one Y column.
2. Open 2D Kernel Density plot dialog by clicking Plot: Statistics: 2D Kernel Density.
3. In the plot_kde2 dialog box, specify the Method , Number of Grid Points in X/Y and the Number of Points to Display, and Plot Type.
4. Click OK to create a 2D Kernel Density plot.

## The Dialog of plot_kde2

 Input Data Specify the input data. Settings Method Specify the calculation method of the 2D Kernel Density plot. Bivariate Kernel Density Estimator Rules of Thumb Number of Grid Points in X/Y Specify the number of equally spaced grid points for the density estimation. Number of Points to Display Specify the first N lowest density points to be superimposed on the density image when the checkbox of All is unchecked. Otherwise, it will display all points when the All checkbox is selected by default. Grid Range As an interim step, a matrix of gridded values is generated from the X/Y data and the kernel density plot is created from the matrix values. By default, the Grid Range registers the minimum and maximum X and Y values in that matrix. Clear the Auto box to enter a value manually. X Minimum X Maximum Y Minimum Y Maximum Plot Type Specify the plot type. Contour Use the density matrix to plot contour Image Use the density matrix to make an image plot Density Estimation data This determines where the calculated data for the graph is stored. Displaying Data This determines where the data of the displayed scatter plot is stored. Only available when Number of Points to Display is not 0.