Five years later, when I Google “how to create a kernel density plot using python”, this thread still shows up at the top!

Today, a much easier way to do this is to use seaborn, a package that provides many convenient plotting functions and good style management.

```
import numpy as np
import seaborn as sns
data = [1.5]*7 + [2.5]*2 + [3.5]*8 + [4.5]*3 + [5.5]*1 + [6.5]*8
sns.set_style('whitegrid')
sns.kdeplot(np.array(data), bw=0.5)
```

### Related Contents:

- Histogram Matplotlib
- A tool to convert MATLAB code to Python [closed]
- How to create a density plot in matplotlib?
- How to plot empirical cdf (ecdf)
- scipy: savefig without frames, axes, only content
- matplotlib – extracting data from contour lines
- Fitting a Normal distribution to 1D data
- Creating a Confidence Ellipsis in a scatterplot using matplotlib
- How do I plot list of tuples in Python?
- how to annotate heatmap with text in matplotlib
- How do I read CSV data into a record array in NumPy?
- Fitting empirical distribution to theoretical ones with Scipy (Python)?
- ImportError: DLL load failed: The specified module could not be found
- How to smooth a curve in the right way?
- Specifying and saving a figure with exact size in pixels
- Computing the correlation coefficient between two multi-dimensional arrays
- Matplotlib: Specify format of floats for tick labels
- find length of sequences of identical values in a numpy array (run length encoding)
- python numpy/scipy curve fitting
- Matplotlib log scale tick label number formatting
- How do I fit a sine curve to my data with pylab and numpy?
- How to remove the space between subplots in matplotlib.pyplot?
- calling dot products and linear algebra operations in Cython?
- No module named when using PyInstaller
- plotting results of hierarchical clustering ontop of a matrix of data in python
- Distance between point and a line (from two points)
- Generating Discrete random variables with specified weights using SciPy or NumPy
- How can I efficiently process a numpy array in blocks similar to Matlab’s blkproc (blockproc) function
- Matplotlib figure to image as a numpy array
- Specify format of floats for tick labels
- Numpy Resize/Rescale Image
- Plotting the data with scrollable x (time/horizontal) axis on Linux
- How do I install SciPy on 64 bit Windows?
- Matplotlib runs out of memory when plotting in a loop
- fitting exponential decay with no initial guessing
- scipy.curve_fit() returns multiple lines
- How to fix ‘numpy.ndarray’ object has no attribute ‘get_figure’ when plotting subplots
- How to get the indices list of all NaN value in numpy array?
- Concatenate sparse matrices in Python using SciPy/Numpy
- plotting a histogram on a Log scale with Matplotlib
- Linear regression of arrays containing NANs in Python/Numpy
- Get coordinates of local maxima in 2D array above certain value
- How to calculate the statistics “t-test” with numpy
- Storing numpy sparse matrix in HDF5 (PyTables)
- 2D and 3D Scatter Histograms from arrays in Python
- Numpy: Divide each row by a vector element
- Principal component analysis in Python
- How to display progress of scipy.optimize function?
- Parse a Pandas column to Datetime when importing table from SQL database and filtering rows by date
- How to add trendline to a scatter plot