Visualization in Python with matplotlib
That's good! Let's fill our empty plot with some data.
We can pass two iterable objects (such as, lists, arrays, tuples) as parameters for the
.plot() function, and they will be used for building the plot. By default, all the points will be connected with the blue line in the respective order as they are stored in the objects.
For example, in the following chapters you will work with the CO2 emission level data. The data is stored as a
Series object with years being indices, and CO2 levels being values. Before we start, let's inspect the data we will work with.
Let's visualize the CO2 emission level over years for Italy.
Here we used indices (the
.index attribute) as values for the x-axis, and emission levels (the
.values attribute) as values for the y-axis. Values for the x-axis were converted into integers (by applying the
.astype() method since Python read them as strings initially).
Disclaimer: FREE DATA FROM WORLD BANK VIA GAPMINDER.ORG, CC-BY LICENSE.