Area plots

An area plot is useful for comparing the values of different factors across a range. The area plot can be stacked in nature, where the areas of the different factors are stacked on top of each other. The following code gives an example of a stacked area plot:

>>> df = pd.DataFrame(np.random.rand(10, 4), columns=['p', 'q', 'r', 's'])

>>> df.plot(kind='area');

After the preceding code is executed we'll get the following output:

Area plots

To remove the stack of area plot, you can use the following code:

>>> df.plot(kind='area', stacked=False);

After the preceding code is executed we'll get the following output:

Get Mastering Python for Data Science now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.