Unit 41Basic Plotting with PyPlot

Plotting for numpy and pandas is provided by the module matplotLib—namely, by the sub-module pyplot.

Let’s start our experimentation with pyplot by invoking the spirit of the NIAAA surveillance report you converted into a frame earlier here, and proceed to plotting alcohol consumption for different states and alcohol kinds over time. Unfortunately, as is always the case with incremental plotting systems, no single function does all of the plotting, so let’s have a look at a complete example:

 import​ matplotlib, matplotlib.pyplot ​as​ plt
 import​ pickle, pandas ​as​ pd
 
 # The NIAAA frame has been pickled before
 alco = pickle.load(open(​"alco.pickle"​, ​"rb"​))
 del​ alco[​"Total"​] ...

Get Data Science Essentials in Python now with O’Reilly online learning.

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