# Plot Multiple Variables On Density Plot in Python

In this article, I will explain you how to plot multiple variables on density plot like two variables density plot and three variables density plot. Density plot require numeric values dataset to display plot in python.

To draw density plot in python use kdeplot() function of seaborn library.

## Installation of Packages

We will need seaborn package to load dataset and plot density graph in python program. If you don’t have these packages installed on your system, install it using below commands.

`pip install seaborn`

Cool Tip: Know more about how to plot histogram with several variables in python!

## Plot Multiple Variables in Density Plot

Let’s see an example to plot two variable density plot in single axis in python using seaborn library.

### Installation of Packages

We will need seaborn package to show density plot. Install package using below command.

`pip install seaborn`

### Import libraries

Import seaborn library in our python density plot code.

```# Import library

import seaborn as sns```

### Prepare dataset

Seaborn library has inbuilt datasets. We will use tips dataset to visualize density plot

• Load tips dataset using load_dataset() function of seaborn library in df variable
• We will use total_bill and tip column from tips dataset.
```# Load the tips dataset

### Plot Density Graph using kdeplot()

Use `sns.kdeplot()`function of seaborn module to draw density graph.

• The first argument in kdeplot() defines dataset use for plot
• The second argument defines shade as true
• The third argument defines color as red for total_bill column and blue color for tip column dataset.
```# Plot 2 variables on Density Graph

### Two Variables on Density Plot Python Code

Use below entire density python code using seaborn library

```# library and dataset
import seaborn as sns

# plot of 2 variables on Density Graph
```

### Two Variables on Density Plot Python Visualization Output

Cool Tip: Know more about how to plot customized line graph in python!

## Plot Three Variables in Density Plot

Let’s see an example to plot three variable density plot in single axis in python using seaborn library.

### Installation of Packages

We will need seaborn package to show density plot. Install package using below command.

`pip install seaborn`

### Import libraries

Import seaborn library in our python density plot code.

```# Import library

import seaborn as sns```

### Prepare dataset

Seaborn library has inbuilt datasets. We will use penguins dataset to visualize density plot

• Load tips dataset using load_dataset() function of seaborn library in df variable
• We will use bill_length_mm, bill_depth_mm and flipper_length_mm columns from penguins dataset.
```# Load the tips dataset

### Plot Density Graph using kdeplot()

Use `sns.kdeplot()`function of seaborn module to draw density graph.

• The first argument in kdeplot() defines dataset use for plot
• The second argument defines shade as true
• The third argument defines color as red for total_bill column and blue color for tip column dataset.
```# plot 3 variables on density graph

### Three Variables on Density Plot Python Code

Use below entire density python code using seaborn library

```# library and dataset
import seaborn as sns

# plot 3 variables on density graph
Use `sns.kdeplot()` function of seaborn module to create density plot in python program.