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
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Controlling Seaborn figure aesthetics


While we can use Matplotlib to customize the figure aesthetics, Seaborn comes with several handy functions to make customization easier. If you are using Seaborn version 0.8 or later, seaborn.set() must be called explicitly after import if you would like to enable the beautiful Seaborn default theme. In earlier versions, seaborn.set() was called implicitly on import.

Preset themes

The five default themes in Seaborn, namely darkgrid, whitegrid, dark, white, and ticks, can be selected by calling the seaborn.set_style() function.

Note

seaborn.set_style() must be called before issuing any plotting commands in order to display the theme properly.

Removing spines from the figure

To remove or adjust the positions of spines, we can make use of the seaborn.despine function. By default, the spines on the top and right side of a figure are removed, and additional spines can be removed by setting left=True or bottom=True. Through the use of offset and trim parameters...