Chapter 3. Visualizing Data
I believe that visualization is one of the most powerful means of achieving personal goals.
A fundamental part of the data scientist’s toolkit is data visualization. Although it is very easy to create visualizations, it’s much harder to produce good ones.
There are two primary uses for data visualization:
To explore data
To communicate data
In this chapter, we will concentrate on building the skills that you’ll need to start exploring your own data and to produce the visualizations we’ll be using throughout the rest of the book. Like most of our chapter topics, data visualization is a rich field of study that deserves its own book. Nonetheless, we’ll try to give you a sense of what makes for a good visualization and what doesn’t.
A wide variety of tools exists for visualizing data. We will be using the
matplotlib library, which is widely used (although sort of showing its age). If you are interested in producing elaborate interactive visualizations for the Web, it is likely not the right choice, but for simple bar charts, line charts, and scatterplots, it works pretty well.
In particular, we will be using the
matplotlib.pyplot module. In its simplest use,
pyplot maintains an internal state in which you build up a visualization step by step. Once you’re done, you can save it (with
savefig()) or display it (with
For example, making simple plots (like Figure 3-1) is pretty simple: