Mastering Matplotlib 2.x - Benjamin Walter Keller - E-Book

Mastering Matplotlib 2.x E-Book

Benjamin Walter Keller

0,0
28,14 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Understand and build beautiful and advanced plots with Matplotlib and Python




Key Features



  • Practical guide with hands-on examples to design interactive plots


  • Advanced techniques to constructing complex plots


  • Explore 3D plotting and visualization using Jupyter Notebook



Book Description



In this book, you'll get hands-on with customizing your data plots with the help of Matplotlib. You'll start with customizing plots, making a handful of special-purpose plots, and building 3D plots. You'll explore non-trivial layouts, Pylab customization, and more about tile configuration. You'll be able to add text, put lines in plots, and also handle polygons, shapes, and annotations. Non-Cartesian and vector plots are exciting to construct, and you'll explore them further in this book. You'll delve into niche plots and visualize ordinal and tabular data. In this book, you'll be exploring 3D plotting, one of the best features when it comes to 3D data visualization, along with Jupyter Notebook, widgets, and creating movies for enhanced data representation. Geospatial plotting will also be explored. Finally, you'll learn how to create interactive plots with the help of Jupyter.






Learn expert techniques for effective data visualization using Matplotlib 3 and Python with our latest offering -- Matplotlib 3.0 Cookbook




What you will learn



  • Deal with non-trivial and unusual plots


  • Understanding Basemap methods


  • Customize and represent data in 3D


  • Construct Non-Cartesian and vector plots


  • Design interactive plots using Jupyter Notebook


  • Make movies for enhanced data representation



Who this book is for



This book is aimed at individuals who want to explore data visualization techniques. A basic knowledge of Matplotlib and Python is required.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 129

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Mastering Matplotlib 2.x
Effective Data Visualization techniques with Python

 

 

 

 

 

 

 

 

 

 

 

 

Benjamin Walter Keller

 

 

 

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Mastering Matplotlib 2.x

Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Commissioning Editor: Pavan RamchandaniAcquisition Editor:Dayne CastelinoContent Development Editor:Ronnel MathewTechnical Editor: Sagar SawantCopy Editor: Safis EditingProject Coordinator:Namrata SwettaProofreader: Safis EditingIndexer:Tejal Daruwale SoniGraphics: Jisha ChirayilProduction Coordinator:Jyoti Chauhan

First published: November 2018

Production reference: 1281118

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78961-769-6

www.packtpub.com

 
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

Packt.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Contributors

About the author

Benjamin Walter Keller is currently a PhD candidate at McMaster University and gained his BSc in physics with a minor in computer science from the University of Calgary in 2011. His current research involves numerical modeling of galaxy evolution over cosmological timescales. As an undergraduate at the U of C, he worked on stacking radio polarization to examine faint extragalactic sources. He also worked in the POSSUM Working Group 2 to determine the requirements for stacking applications for the Australian SKA Pathfinder (ASKAP) radio telescope. He is particularly interested in questions involving stellar feedback (supernovae, stellar winds, and so on) and its impact on galaxies and their surrounding intergalactic medium.

 

 

 

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Mastering Matplotlib 2.x

About Packt

Why subscribe?

Packt.com

Contributors

About the author

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Heavy Customization

Customizing PyLab using style

How to use styles to change the appearance of our plots

Different Matplotlib styles

Creating your own styles

Deep diving into color

Questions to ask when choosing a color map

Using color maps

Working on non-trivial layouts

The Matplotlib configuration files

Matplotlibrc – where does it live?

Summary

Drawing on Plots

Putting lines in place

Adding horizontal and vertical lines

Adding spans that cover whole regions

Adding and tweaking a background grid

Adding text on your plots

Adding text to both axis and figure objects

Adding text in multi-panel figures

Playing with polygons and shapes

Adding polygons and shapes to our plots

The built-in shapes that Matplotlib provides

Building your own polygons

Versatile annotating

Adding arrows to our plots with the annotate method

Adding some text to the arrows

Customizing the appearance of the annotations

Summary

Special Purpose Plots

Non-Cartesian plots

Creating polar axes

Applying log, symmetric log, and logistic scales to your axes

Plotting vector fields

Making vector plots with quiver

Customizing the appearance of vector plots

Annotating vector plots with a quiver key

Making stream plots

Statistics with boxes and violins

Making box plots to show the interquartile ranges and the outliers

Making violin plots show different distributions

Customizing the appearance of plots

Visualizing ordinal and tabular data

Pie charts

Tables

Customizing the appearance of plots

Summary

3D and Geospatial Plots

Plotting with 3D axes

How to add 3D axes to a figure

How to use the interactive backend to manipulate the 3D plots

How to plot on the 3D axes

Looking at various 3D plot types

How to rotate the camera in 3D plots

How to add line and scatter plots

How to add wireframe, surface, and triangular surface plots

How to add 3D contour types

The basemap methods

How to create map projections

How to choose between different kinds of map projections

Further reading

Plotting on map projections

How to add simple points and lines to our plots

How to draw great circles

How to draw a day/night terminator

Adding geography

How to add coastline and water features

How to add political boundaries for countries, states, and provinces

Summary

Interactive Plotting

Interactive plots in the Jupyter Notebook

How to install and enable the ipywidgets module

How to use the interact method to make basic widgets

How to view the different kinds of widgets that ipywidgets provides

How to customize widgets

Event handling with plot callbacks

How to add interactivity by capturing mouse events

How to capture keyboard clicks

How to use the picker to manipulate plots

GUI neutral widgets

How to add the basic GUI neutral widgets

A selection of the different kinds of widgets that are available in Matplotlib

How to add interactivity to these widgets using callbacks

Making movies

How to generate animations to make plots that update themselves

How to customize the animation frame rate, speed, and repetitions

How to save animations as mp4 videos and animated GIFs

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Mastering Matplotlib covers use cases and unusual cases that require powerful tools. With easy-to-follow examples and the high-end components of Matplotlib, this book will enable you to develop advanced and interactive plots using Python scripting and Matplotlib. 

Matplotlib is a multi-platform data visualization tool built upon the NumPy and SciPy frameworks. One of Matplotlib's most important features is its ability to work well with many operating systems and graphics backends. In this book, you'll get hands-on with customizing your data plots with the help of Matplotlib. You'll start with customizing plots, making a handful of special-purpose plots, and building 3D plots. You'll explore non-trivial layouts, Pylab customization, and tile configuration. You'll be able to add text, put lines in plots, and also handle polygons, shapes, and annotations. Non-Cartesian and vector plots are exciting to construct, and you'll explore them further in this book. You'll delve into niche plots and visualize ordinal and tabular data.

In this book, you'll be exploring 3D plotting, one of the best features when it comes to 3D data visualization, along with Jupyter Notebook, widgets, and creating movies for enhanced data representation. Geospatial plotting will be also be explored. Finally, you'll learn how to create interactive plots with the help of Jupyter. By the end of this book, you'll be able to construct advanced plots with additional customization techniques and 3D plot types.

Who this book is for

This book is aimed at individuals who want to explore data visualization techniques. Basic knowledge of Matplotlib and Python is required.

What this book covers

Chapter 1, Heavy Customization, covers customizing Pylab and also learn about working on non-trivial layouts and the different Matplotlib configuration files.

Chapter 2, Drawing on Plots, explains how to put lines in place and add text to your plots. We will also learn about playing with polygons, shapes, and versatile annotating.

Chapter 3, Special Purpose Plots, covers non-Cartesian plots and plotting vector fields. We will also learn about statistics with boxes and violins, and also visualize ordinal and tabular data.

Chapter 4, 3D and Geospatial, explores plotting with 3D axes, looking at the various 3D plot types and the Basemap methods. We will also learn about plotting on map projections and adding geography.

Chapter 5, Interactive Plotting, looks at interactive plots in Jupyter Notebook and event handling with plot callbacks. We will also learn about GUI neutral widgets and how to make movies.

To get the most out of this book

The readers should have basic knowledge of Python.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packt.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Matplotlib-2.x. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: http://www.packtpub.com/sites/default/files/downloads/9781789617696_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The easiest way to do this is to remove the plot keyword and call semilogy."

A block of code is set as follows:

import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib inline

Any command-line input or output is written as follows:

$ mkdir css

$ cd css

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

Heavy Customization

This book will teach us about advanced Matplotlib plots. It will enable you to go from data to plot to insight, in order to take raw numbers, raw information, and turn them into a visualization, which will allow us to build within our mind the actual bit of insight on how the data behaves. This will also focus on the advanced tools to derive more subtle insights from your data. 

In this chapter, we will be focusing on the advanced tools of plotting so that you can really derive more subtle insights from your data. The prerequisites for this course give us a basic understanding of Python and the ability to use NumPy to work with array data.

We will learn about the following topics:

Using style sheets to customize our plot's appearance

Working with Matplotlib colors

Building multi-panel plots with complex layouts

How to configure Matplotlib to use our preferences whenever we start up a new Matplotlib session