The basics

The matplotlib package is rather large, since it encompasses quite a lot of functionality. Fortunately for us, for most of our plotting tasks, all we need is the pyplot module, which provides a MATLAB-like plotting framework. Occasionally, we will need to import additional modules for other tasks, such as animations, changing the style, or altering the default parameters. The following code block is how pyplot is traditionally imported in Python, using the alias plt:

import matplotlib.pyplot as plt
Notice that, rather than importing the whole package, we only import the module using the dot notation; this reduces the amount of typing we need to do in order to access what we need, and we don't take up more space in memory with code ...

Get Hands-On Data Analysis with Pandas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.