Book Image

Matplotlib 2.x By Example

By : Allen Yu, Claire Chung, Aldrin Yim
Book Image

Matplotlib 2.x By Example

By: Allen Yu, Claire Chung, Aldrin Yim

Overview of this book

Big data analytics are driving innovations in scientific research, digital marketing, policy-making and much more. Matplotlib offers simple but powerful plotting interface, versatile plot types and robust customization. Matplotlib 2.x By Example illustrates the methods and applications of various plot types through real world examples. It begins by giving readers the basic know-how on how to create and customize plots by Matplotlib. It further covers how to plot different types of economic data in the form of 2D and 3D graphs, which give insights from a deluge of data from public repositories, such as Quandl Finance. You will learn to visualize geographical data on maps and implement interactive charts. By the end of this book, you will become well versed with Matplotlib in your day-to-day work to perform advanced data visualization. This book will guide you to prepare high quality figures for manuscripts and presentations. You will learn to create intuitive info-graphics and reshaping your message crisply understandable.
Table of Contents (15 chapters)
Title Page
About the Authors
About the Reviewer
Customer Feedback

Chapter 3. Figure Layout and Annotations

A picture is worth a thousand words. Photographers and painters need to plan their picture composition, and so do data graphics designers. Layout is an important aspect of creating an appealing figure.

Sometimes, your story weighs more than a thousand words to be told via a single figure. We often see a group of relevant plots lying adjacently to deliver a message in multiple aspects.

Just as you may quote some particular phrases in a book paragraph or comment your code for easier comprehension, it is also likely that we need extra annotation to point out areas of emphasis in plots. Now we have mastered the basic techniques to adjust the look and feel in a single plot, in this chapter, we will go through the following topics:

  • Layout:
    • Adjusting the size of the figure
    • Modifying or removing spines
    • Multiple plots within the same figure
    • Adding subplots
    • Adding inset plots
    • Adjusting margins
  • Annotations:
    • Adding basic annotations
    • Adding a textbox
    • Adding shapes