Other Tools for Visualization
11.7. Other Tools for Visualization¶
There are many software packages and tools for creating data visualizations.
In this book, we primarily use
But it’s worth knowing about a few other commonly used tools.
In this section, we compare
matplotlib and grammar of graphics
matplotlib is one of the first data visualization tools for Python.
Because of this, it is widely used and has a large ecosystem of packages.
Notably, the built-in plotting methods for
make plots using
One popular package that builds on top of
matplotlib is called seaborn.
seaborn provides a much simpler API to create statistical plots, like
dot plots with confidence intervals.
seaborn’s API was used as an inspiration for
If you look at
plotly code and
seaborn code side-by-side, you’ll find that
the methods to create basic plots use similar code.
One advantage of using
matplotlib is its popularity.
It’s relatively easy to find help creating or fine-tuning plots online because
many existing projects use it.
For this book, the main advantage of using
plotly is that the plots we
create are interactive.
matplotlib are usually static images, which don’t allow for panning,
zooming, or hovering over marks.
Still, we expect that
matplotlib will continue to be used for data analyses
so we think it’s worth learning the basics by looking through its
11.7.2. Grammar of Graphics¶
The grammar of graphics is a mathematical theory for creating data visualizations [Wilkinson, 2012]. The basic idea is to use common building blocks for making plots. For instance, a bar plot and a dot plot are nearly identical, except that a bar plot draws rectangles and a dot plot draws points. This idea is captured in the grammar of graphics, which would say that a bar plot and a dot plot differ only in their “geometry” component. The grammar of graphics is an elegant system that we can use to describe nearly every kind of plot we wish to make.
This system is implemented in the popular plotting libraries
ggplot2 for the
R programming language and
A Python package called altair provides a way to create
vega plots using
Python, and we encourage interested readers to look over its documentation.
Using a grammar of graphics tool like
altair enables flexibility in visualizations.
altair also creates interactive visualizations.
However, the Python API for these tools can be less straightforward than
In this book, we don’t typically need plots outside of what
plotly is capable
of creating, so we have opted for
plotly’s simpler API.
There are many more plotting tools for Python that we’ve left out for brevity.
But for the purposes of this book, relying on
plotly provides a useful
balance of interactivity and flexibility.