Chapter 4 Plotting: matplotlib and seaborn

import numpy as np
np.random.seed(10)

Python has many plotting libraries. Here we discuss some of the simplest ones, matplotlib and seaborn. Matplotlib is in a sense a very basic plotting library, oriented on vectors, not datasets (in this sense comparable to base-R plotting). But it is very widely used, and with a certain effort, it allows to create very nice looking plots. It is also easier to tinker with the lower level features in matplotlib, compared to the more high-level data oriented libraries.

Seaborn is such a high-level data oriented plotting library (comparable to ggplot in R in this sense). It has ready-made functionality to pick variables from datasets and modify the visual properties of lines and points depending on other values in data.

We assume you have imported the following modules: