Matplotlib is a Python library used to create charts and graphs.
In this first lesson, you will get an overview of the basic commands necessary to build and label a line graph. The concepts you will learn include:
- Creating a line graph from data
- Changing the appearance of the line
- Zooming in on different parts of the axis
- Putting labels on titles and axes
- Creating a more complex figure layout
- Adding legends to graphs
- Changing tick labels and positions
- Saving what you’ve made
By the end of the lesson, you’ll be well on your way to becoming a master at presenting and organizing your data in Python.
To the right, you can see an example of the kind of chart you’ll be able to make by the end of this lesson!
Instructions
Before we start working with Matplotlib, we need to import
it into our Python environment.
Paste the following code into script.py:
from matplotlib import pyplot as plt
This will import the plotting functions from matplotlib, and make them accessible using the shorter name plt
. Most of the commands we will learn will start with plt.
going forward.