matplotlib Plotting Cookbook

Book description

Discover how easy it can be to create great scientific visualizations with Python. This cookbook includes over sixty matplotlib recipes together with clarifying explanations to ensure you can produce plots of high quality.

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.

What You Will Learn

  • 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

Table of contents

  1. matplotlib Plotting Cookbook
    1. Table of Contents
    2. matplotlib Plotting Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. First Steps
      1. Introduction
      2. Installing matplotlib
        1. How to do it...
      3. Plotting one curve
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Using NumPy
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Plotting multiple curves
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Plotting curves from file data
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Plotting points
        1. How to do it...
        2. How it works...
      8. Plotting bar charts
        1. How to do it...
        2. How it works...
        3. There's more...
          1. The thickness of a bar
          2. Horizontal bars
      9. Plotting multiple bar charts
        1. How to do it...
        2. How it works...
        3. There's more...
      10. Plotting stacked bar charts
        1. How to do it...
        2. How it works...
        3. There's more...
      11. Plotting back-to-back bar charts
        1. How to do it...
        2. How it works...
      12. Plotting pie charts
        1. How to do it...
        2. How it works...
      13. Plotting histograms
        1. How to do it...
        2. How it works...
      14. Plotting boxplots
        1. How to do it...
        2. How it works...
        3. There's more...
      15. Plotting triangulations
        1. How to do it...
        2. How it works...
    9. 2. Customizing the Color and Styles
      1. Introduction
      2. Defining your own colors
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Using custom colors for scatter plots
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Using custom colors for bar charts
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Using custom colors for pie charts
        1. How to do it...
        2. How it works...
      6. Using custom colors for boxplots
        1. How to do it...
        2. How it works...
      7. Using colormaps for scatter plots
        1. How to do it...
        2. How it works...
      8. Using colormaps for bar charts
        1. How to do it...
        2. How it works...
      9. Controlling a line pattern and thickness
        1. How to do it...
        2. How it works...
        3. There's more...
          1. The line style with other plot types
          2. The line width
      10. Controlling a fill pattern
        1. How to do it...
        2. How it works...
      11. Controlling a marker's style
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      12. Controlling a marker's size
        1. How to do it...
        2. There's more...
      13. Creating your own markers
        1. How to do it...
        2. How it works...
      14. Getting more control over markers
        1. How to do it...
        2. How it works...
      15. Creating your own color scheme
        1. How to do it...
        2. How it works...
        3. There's more...
    10. 3. Working with Annotations
      1. Introduction
      2. Adding a title
        1. How to do it...
        2. How it works...
      3. Using LaTeX-style notations
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Adding a label to each axis
        1. How to do it...
        2. How it works...
      5. Adding text
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Alignment control
          2. Bounding box control
      6. Adding arrows
        1. How to do it...
        2. How it works...
      7. Adding a legend
        1. How to do it...
        2. How it works...
        3. There's more...
      8. Adding a grid
        1. How to do it...
        2. How it works...
      9. Adding lines
        1. How to do it...
        2. How it works...
      10. Adding shapes
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Working with polygons
          2. Working with path attributes
      11. Controlling tick spacing
        1. How to do it...
        2. How it works...
        3. There's more...
      12. Controlling tick labeling
        1. How to do it...
        2. How it works...
        3. There's more...
          1. A simpler way to create bar charts with fixed labels
          2. Advanced label generation
    11. 4. Working with Figures
      1. Introduction
      2. Compositing multiple figures
        1. How to do it...
        2. How it works...
        3. There's more...
          1. An alternative way to composite figures
      3. Scaling both the axes equally
        1. How to do it...
        2. How it works...
      4. Setting an axis range
        1. How to do it...
        2. How it works...
      5. Setting the aspect ratio
        1. How to do it...
        2. How it works...
      6. Inserting subfigures
        1. How to do it...
        2. How it works...
      7. Using a logarithmic scale
        1. How to do it...
        2. How it works...
        3. There's more...
      8. Using polar coordinates
        1. How to do it...
        2. How it works...
        3. There's more...
    12. 5. Working with a File Output
      1. Introduction
      2. Generating a PNG picture file
        1. How to do it...
        2. How it works...
      3. Handling transparency
        1. How to do it...
          1. Rendering a figure to a PNG file with a transparent background
          2. Making a HTML page that includes the figure
        2. How it works...
        3. There's more...
      4. Controlling the output resolution
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Generating PDF or SVG documents
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Handling multiple-page PDF documents
        1. How to do it...
        2. How it works...
        3. There's more...
    13. 6. Working with Maps
      1. Introduction
      2. Visualizing the content of a 2D array
        1. How to do it...
        2. How it works...
        3. There's more…
      3. Adding a colormap legend to a figure
        1. How to do it...
        2. How it works...
      4. Visualizing nonuniform 2D data
        1. How to do it...
        2. How it works...
      5. Visualizing a 2D scalar field
        1. How to do it...
        2. How it works...
      6. Visualizing contour lines
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Visualizing a 2D vector field
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Visualizing the streamlines of a 2D vector field
        1. How to do it...
        2. How it works...
        3. There's more...
    14. 7. Working with 3D Figures
      1. Introduction
      2. Creating 3D scatter plots
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Creating 3D curve plots
        1. How to do it…
        2. How it works...
      4. Plotting a scalar field in 3D
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Plotting a parametric 3D surface
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Embedding 2D figures in a 3D figure
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Creating a 3D bar plot
        1. How to do it...
        2. How it works...
    15. 8. User Interface
      1. Introduction
      2. Making a user-controllable plot
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Integrating a plot to a Tkinter user interface
        1. How to do it...
        2. How it works...
      4. Integrating a plot to a wxWidgets user interface
        1. How to do it...
        2. How it works...
      5. Integrating a plot to a GTK user interface
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Integrating a plot in a Pyglet application
        1. How to do it...
        2. How it works...
    16. Index

Product information

  • Title: matplotlib Plotting Cookbook
  • Author(s): Alexandre Devert
  • Release date: March 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781849513265