Matplotlib is a cross-platform data visualization library. It’s used to visualize data and the results of all sorts of computations. Matplotlib is mainly used for static 2D and 3D graphs.
Its capabilities are huge, of which we’re only going to cover the basics in this series. We’ll use quite a lot of different types of plots, like line plots, bar plots, colormap plots, contour plots or 3D surface plots.
Matplotlib supports a variety of output formats. You are also in full control of the appearance of the graphs and the elements that should be visible on the graph, like annotations, scales, legends and so on. Matplotlib is used to make publication-ready figures.
If you want to learn more about the library, in particular read the current documentation, you should visit the matplotlib.org website. There you can also find lots of interesting examples and tutorials. Here’s what it looks like at the time of writing:
In this series we’ll be using the Jupyter Notebook environment. If you want to follow along, make sure you have matplotlib and the environment installed. You already have it if you have the Anaconda distribution of Python.
Opening Jupyter Notebook
You can open Jupyter Notebook from the Anaconda Prompt terminal by typing the following:
This will open Jupyter:
You will see it in your browser at localhost:8888:
In this series we want each part to have its own notebook, so let’s create a folder where we will store them all. To do that, click on New and select Folder:
Let’s rename the folder matplotlib. First select the folder (A) and then hit Rename (B):
Now a popup window will show. Enter the new name (A) and hit the Rename button (B):
Now you can see the renamed folder in the list:
We are ready to start coding. In the next lecture we’ll write some simple code using Matplotlib just to see what modules we need and how the code is organized.
Here’s the video version of the article: