Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Data visualization with matplotlib (and its pandas interface)

We had experience working with matplotlib alreadyfirst, in Chapter 3Functions, and later, in Chapter 8, Simulation with Classes and Inheritance. Luckily, pandas has a built-in interface for working with matplotlib, making visualization very easy and intuitive. But first, we need to prepare the Notebook to display charts:

%matplotlib inlineimport pylab as pltplt.style.use('fivethirtyeight')

Now, let's plot the histogram of total casualties. It's possible to do that with the matplotlib itselfbut pandas has a simple interface built-in. For better or worse, we still have to set labels and titles via a standard matplotlib interfacein this case, as follows:

data.loc[~mask, 'killed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content