The cookbook is a place for community contributions of recipes, howtos and examples.
Complete documentation and tutorials for matplotlib can be found at matplotlib's webpage
Simple Plotting
Sigmoidal Functions - plotting simple functions
Multiline Plots - how to plot multiple lines over one another
Bar Charts - how to make a bar chart
Common Errors - Compilation of common errors that can cause erroneous behavior. Check before emailing mailing lists.
/Animations - how to animate your figures.
Multicolored Line - different colors for different parts of a line
Shaded Regions - how to plot grey shaded regions using transparency.
/Arrows - how to plot arrows
Unfilled Histograms - how to plot histograms that are un-filled and don't look like bar charts.
Cookbook/Histograms - 2D histograms with variable bin width.
Custom Log Plot Labels - plotting log plots with custom tick labels that are formatted as integer numbers rather than exponents as is the default.
Thick Axes - how to make thick axes lines and bold fonts.
/Maps - how to plot data on map projections
Plotting values with masked arrays - How to plot only selected values of an array, because some values are meaningless (detector malfunction), out of range, etc. etc.
/Transformations - Using transformations to convert between different coordinate systems.
TreeMap - classic treemap style plots
/Legend - Adding a legend to your plot
Hinton Diagrams - A way of visualizing weight matrices
Pseudo Color Plots
Loading a colormap dynamically - How to load a color map from a GMT (Generic Mapping Tools) file.
Show colormaps - Small script to display all of the Matplotlib colormaps, and an exampleshowing how to create a new one.
Converting a matrix to a raster image - A replacement for scipy's imsave command
Gridding irregularly spaced data - how to grid scattered data points in order to make a contour or image plot.
Plotting Images with Special Values - how to plot an image with special values mapped to specific colors, e.g. missing values or data extrema
Transformations on Colormaps - how to apply a function to the look up table of a colormap and turn it into another one.
Typesetting
Using TeX - formatting matplotlib text with LaTeX
LaTeX Examples - Complete examples for generating publication quality figures using LaTeX.
3D Plotting
NOTE: Experimental work has been going on to integrate 3D plotting functionality into matplotlib. Please see the related mplot3d documentation or take a look at matplotlib gallery for example 3D plots. For a more sophisticated 3D visualization and plotting interface, you can try Mayavi which is actively maintained and features an 'mlab' interface similar to matplotlib's 'pylab'. |
3D plots - Simple 3D plots using matplotlibs built-in 3D functions (which were originally provided by John Porter's mplot3d add-on module).
VTK Integration - How to import plots into VTK.
Embedding Plots in Apps
Embedding in WX - Advice on how to embed matplotlib figures in wxPython applications.
WxMpl - Python module for integrating matplotlib into wxPython GUIs.
Cookbook/Matplotlib/ScrollingPlot - Demonstrates how to control a matplotlib plot embedded in a wxPython application with scrollbars.
Gael Varoquax's scientific GUI tutorial - Includes an instructive example of embedding matplotlib in a Traits GUI.
Cookbook/Matplotlib/PySide - Demonstrates how to display a matplotlib plot embedded in a PySide (Qt) application
Misc
Load and display an image - shows a simple way to import a PNG image to a numpy array
Interactive Plotting - Adding mouse interaction to identify data annotations.
Matplotlib and Zope - How to use Matplotlib within the application server Zope.
Qt with IPython and Designer - How to design a GUI using Qt's Designer tool using Matplotlib widgets, and that can be interactively controlled from the IPython command line.
Compiling Matplotlib on Solaris 10 - how to compile the thing on Solaris 10, using gcc/g++
Using MatPlotLib in a CGI script - steps needed to be able to use matplotlib from a python cgi script
Making Dynamic Charts for your Webpage - Complete CGI script example.
matplotlib without GUI by Andrew Dalke.
Andrew Straw's Apt Repository - Bleeding edge deb packages for Debian, Ubuntu (also has packages for numpy/scipy etc.).
Adjusting Image Size - a brief discussion of how to adjust the size of figures -- for printing, web, etc.
Deleting An Existing Data Series - a quick example showing how to remove one data series from an already existing plot.
Embedding in Django - example on how to use matplotlib with Django.
timeseries scikit - The documentation contains a section on plotting TimeSeries objects using matplotlib
/TreeMap - A compact way of showing weighted tree information.
Multiple Subplots with One Axis Label - how to use one centered label to annotate several subplots
Multiple Y-axis - How to plot different variables on the same plot but different Y-Axis (one left and one right)
Creating video of 3D graph plotting using matplotlib and mencoder by Ilya Zakreuski