Files
labs/Module-2/7.Matplot/1-Introduction-To-Matplotlib.ipynb
T

2.5 KiB

Visualization with Matplotlib

Importing Matplotlib

Just as we use the np shorthand for NumPy and the pd shorthand for Pandas, we will use some standard shorthands for Matplotlib imports:

In [ ]:
import matplotlib as mpl
import matplotlib.pyplot as plt

The plt interface is what we will use most often, as you shall see throughout this part of the book.

Setting Styles

We will use the plt.style directive to choose appropriate aesthetic styles for our figures. Here we will set the classic style, which ensures that the plots we create use the classic Matplotlib style:

In [ ]:
plt.style.use('classic')
In [ ]:
%matplotlib inline
In [ ]:
import numpy as np
x = np.linspace(0, 10, 100)

fig = plt.figure()
plt.plot(x, np.sin(x), '-')
plt.plot(x, np.cos(x), '--');