matplotlib Plotting Cookbook

matplotlib Plotting Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Learn plotting with self-contained, practical examples that cover common use cases
  • Build your own solutions with the orthogonal recipes
  • Learn to customize and combine basic plots to make sophisticated figures

Book Details

Language : English
Paperback : 222 pages [ 235mm x 191mm ]
Release Date : March 2014
ISBN : 1849513260
ISBN 13 : 9781849513265
Author(s) : Alexandre Devert
Topics and Technologies : All Books, Application Development, Cookbooks, Open Source

Table of Contents

Chapter 1: First Steps
Chapter 2: Customizing the Color and Styles
Chapter 3: Working with Annotations
Chapter 4: Working with Figures
Chapter 5: Working with a File Output
Chapter 6: Working with Maps
Chapter 7: Working with 3D Figures
Chapter 8: User Interface
  • Chapter 1: First Steps
    • Introduction
    • Installing matplotlib
    • Plotting one curve
    • Using NumPy
    • Plotting multiple curves
    • Plotting curves from file data
    • Plotting points
    • Plotting bar charts
    • Plotting multiple bar charts
    • Plotting stacked bar charts
    • Plotting back-to-back bar charts
    • Plotting pie charts
    • Plotting histograms
    • Plotting boxplots
    • Plotting triangulations
  • Chapter 2: Customizing the Color and Styles
    • Introduction
    • Defining your own colors
    • Using custom colors for scatter plots
    • Using custom colors for bar charts
    • Using custom colors for pie charts
    • Using custom colors for boxplots
    • Using colormaps for scatter plots
    • Using colormaps for bar charts
    • Controlling a line pattern and thickness
    • Controlling a fill pattern
    • Controlling a marker's style
    • Controlling a marker's size
    • Creating your own markers
    • Getting more control over markers
    • Creating your own color scheme
  • Chapter 3: Working with Annotations
    • Introduction
    • Adding a title
    • Using LaTeX-style notations
    • Adding a label to each axis
    • Adding text
    • Adding arrows
    • Adding a legend
    • Adding a grid
    • Adding lines
    • Adding shapes
    • Controlling tick spacing
    • Controlling tick labeling
  • Chapter 4: Working with Figures
    • Introduction
    • Compositing multiple figures
    • Scaling both the axes equally
    • Setting an axis range
    • Setting the aspect ratio
    • Inserting subfigures
    • Using a logarithmic scale
    • Using polar coordinates
  • Chapter 5: Working with a File Output
    • Introduction
    • Generating a PNG picture file
    • Handling transparency
    • Controlling the output resolution
    • Generating PDF or SVG documents
    • Handling multiple-page PDF documents
  • Chapter 6: Working with Maps
    • Introduction
    • Visualizing the content of a 2D array
    • Adding a colormap legend to a figure
    • Visualizing nonuniform 2D data
    • Visualizing a 2D scalar field
    • Visualizing contour lines
    • Visualizing a 2D vector field
    • Visualizing the streamlines of a 2D vector field
  • Chapter 7: Working with 3D Figures
    • Introduction
    • Creating 3D scatter plots
    • Creating 3D curve plots
    • Plotting a scalar field in 3D
    • Plotting a parametric 3D surface
    • Embedding 2D figures in a 3D figure
    • Creating a 3D bar plot
  • Chapter 8: User Interface
    • Introduction
    • Making a user-controllable plot
    • Integrating a plot to a Tkinter user interface
    • Integrating a plot to a wxWidgets user interface
    • Integrating a plot to a GTK user interface
    • Integrating a plot in a Pyglet application

Alexandre Devert

Alexandre Devert is a scientist, currently busy solving problems and making tools for molecular biologists. Before this, he used to teach data mining, software engineering, and research in numerical optimization. He is an enthusiastic Python coder as well and never gets enough of it!

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

matplotlib Plotting Cookbook +    Blender 3D Basics =
50% Off
the second eBook
Price for both: €30.40

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Discover how to create all the common plots you need
  • Enrich your plots with annotations and sophisticated legends
  • Take control of your plots and master colors, linestyle, and scales
  • Add a dimension to your plots and go 3D
  • Integrate your graphics into your applications
  • Automate your work and generate a large batch of graphics
  • Create interactive plots with matplotlib
  • Combine your plots to create sophisticated visualizations

In Detail

matplotlib is part of the Scientific Python modules collection. matplotlib provides a large library of customizable plots and a comprehensive set of backends. It tries to make easy things easy and hard things possible. You can generate plots, add dimensions to the plots, and also make the plots interactive with just a few lines of code with matplotlib. Also, matplotlib integrates well with all common GUI modules.

This book is a head-first, hands-on journey into matplotlib, the complete and definite plotting package for Python. You will learn about the basic plots, how to customize them, and combine them to make sophisticated figures. Along with basic plots, you will also learn to make professional scientific plots.

In this book, you will start with the common figures that are offered by most plotting packages. You will learn how to add annotations, and play with styles, colors, scales, and shapes so that you can add personality and visual punch to your graphics. You will also see how to combine several graphics. With this book you will learn how to create sophisticated visualizations with simple code. Finally, you can make your plots interactive.

After reading "matplotlib Plotting Cookbook", you will be able to create the highest quality plots.


This book follows a cookbook style approach that puts orthogonal and non-redundant recipes in your hands. Rather than rehashing the user manual, the explanations expose the underlying logic behind matplotlib.

Who this book is for

If you are an engineer or scientist who wants to create great visualizations with Python, rather than yet another specialized language, this is the book for you. While there are several very competent plotting packages, matplotlib is “just” a Python module. Thus, if you know some Python already, you will feel at home from the first steps on. In case you are an application writer, you won't be left out since the integration of matplotlib is covered.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software