Pandas is a data analysis and manipulation module that helps you load and parse data. That is a module you’ll probably use when creating plots.

In Pandas, data is stored in data frames. For instance, if you load data from Excel. Of course you don’t have to use Pandas when working with data, just as you don’t have to use a car when travelling. But it makes working with data much easier.

Related course: Matplotlib Examples and Video Course

example

seaborn pandas

The seaborn pandas plot is created from the pandas dataframe. The data frame uses random data, but in practice this data often comes from databases, Excel or other sources.

The program creates different plots but for simplicity only one result is shown.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns


df_obj1 = pd.DataFrame({"x": np.random.randn(500),
"y": np.random.randn(500)})

df_obj2 = pd.DataFrame({"x": np.random.randn(500),
"y": np.random.randint(0, 100, 500)})


sns.jointplot(x="x", y="y", data=df_obj2)
sns.jointplot(x="x", y="y", data=df_obj2, kind="hex");
sns.jointplot(x="x", y="y", data=df_obj1, kind="kde");
dataset = sns.load_dataset("tips")
sns.pairplot(dataset);

#titanic = sns.load_dataset('titanic')
#planets = sns.load_dataset('planets')
#flights = sns.load_dataset('flights')
#iris = sns.load_dataset('iris')
exercise = sns.load_dataset('exercise')
sns.stripplot(x="diet", y="pulse", data=exercise)
sns.swarmplot(x="diet", y="pulse", data=exercise, hue='kind')
sns.boxplot(x="diet", y="pulse", data=exercise)
sns.boxplot(x="diet", y="pulse", data=exercise, hue='kind')
sns.violinplot(x="diet", y="pulse", data=exercise, hue='kind')
sns.barplot(x="diet", y="pulse", data=exercise, hue='kind')
sns.pointplot(x="diet", y="pulse", data=exercise, hue='kind');

plt.show()

seaborn pandas

If you are new to matplotlib, then I highly recommend this course.