Unit 41 | Basic 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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.