Chapter 7. Data Visualization
Use a picture. It’s worth a thousand words.
Arthur Brisbane (1911)
This chapter is about the basic visualization capabilities of the matplotlib
and plotly
packages.
Although there are more visualization packages available, matplotlib
has established itself as the benchmark and, in many situations, a robust and reliable visualization tool. It is both easy to use for standard plots and flexible when it comes to more complex plots and customizations. In addition, it is tightly integrated with NumPy
and pandas
and the data structures they provide.
matplotlib
only allows for the generation of plots in the form of bitmaps (for example, in PNG or JPG format). On the other hand, modern web technologies—based, for example, on the Data-Driven Documents (D3.js) standard—allow for nice interactive and also embeddable plots (interactive, for example, in that one can zoom in to inspect certain areas in greater detail). A package that makes it convenient to create such D3.js plots with Python is plotly
. A smaller additional library, called Cufflinks
, tightly integrates plotly
with pandas
DataFrame
objects and allows for the creation of popular financial plots (such as candlestick charts).
This chapter mainly covers the following topics:
- “Static 2D Plotting”
-
This section introduces
matplotlib
and presents a selection of typical 2D plots, from the most simple to some more advanced ones with two scales or different subplots. - “Static 3D Plotting”
-
Based on
matplotlib ...
Get Python for Finance, 2nd Edition 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.