Skip to content

Introduction

What is Matplotlib?

First things first: The name comes from Matrix Plotting Library, not “Math…”.

Matplotlib ia a framework - i.e. a collection of functionality, not a program on its own. Its main use case is generating data visualizations. The framework produces high quality images based on the data given and is very customizable. It integrates well with other commonly used Python-frameworks like numpy or pandas.

How to get matplotlib?

It can be installed via the command line using pip:

pip install matplotlib

Graphical tools like thonny, anaconda or pycharm usually have a menu to install such packages.

Where to find help?

All the important links and additional material is collected in the Further Reading section


Anatomy of a Plot

Knowing the right terms for the subject can help to better search for help, understand documentation and communicate issues and solutions. In the following image you can find the naming of the elements in a plot as used by matplotlib:

Picture: A plot with its elements marked

There are further terms that you may want to keep in mind when working with the framework.

Common Pitfall

In the nomenclature of the framework there is a difference between

  • Axis: the number line that gets printed on the side of the plot
  • Axes: the collection of all plotted elements that represent data (roughly: the plotting area)

Artists and Figures

An artist determines the rendering style of plot elements. The figure is the collection of all plot elements. Figures can be nested into other figures. The nested element is called a sub-figure. Implementation-wise, the figure is an artist (i.e. it controls its own plotting style). The rectangle for the figure’s background is contained in the attribute patch.