History#
Note
The following introductory text was written in 2008 by John D. Hunter(1968-2012), the original author of Matplotlib.
Matplotlib is a library for making 2D plots of arrays inPython. Although it has its origins in emulatingthe MATLAB graphics commands, it isindependent of MATLAB, and can be used in a Pythonic, object-orientedway. Although Matplotlib is written primarily in pure Python, itmakes heavy use ofNumPy and other extensioncode to provide good performance even for large arrays.
Matplotlib is designed with the philosophy that you should be able tocreate simple plots with just a few commands, or just one! If youwant to see a histogram of your data, you shouldn't need toinstantiate objects, call methods, set properties, and so on; itshould just work.
For years, I used to use MATLAB exclusively for data analysis andvisualization. MATLAB excels at making nice looking plots easy. WhenI began working with EEG data, I found that I needed to writeapplications to interact with my data, and developed an EEG analysisapplication in MATLAB. As the application grew in complexity,interacting with databases, http servers, manipulating complex datastructures, I began to strain against the limitations of MATLAB as aprogramming language, and decided to start over in Python. Pythonmore than makes up for all of MATLAB's deficiencies as a programminglanguage, but I was having difficulty finding a 2D plotting package(for 3DVTK more than exceeds all of myneeds).
When I went searching for a Python plotting package, I had severalrequirements:
Plots should look great - publication quality. One importantrequirement for me is that the text looks good (antialiased, etc.)
Postscript output for inclusion with TeX documents
Embeddable in a graphical user interface for applicationdevelopment
Code should be easy enough that I can understand it and extendit
Making plots should be easy
Finding no package that suited me just right, I did what anyself-respecting Python programmer would do: rolled up my sleeves anddived in. Not having any real experience with computer graphics, Idecided to emulate MATLAB's plotting capabilities because that issomething MATLAB does very well. This had the added advantage thatmany people have a lot of MATLAB experience, and thus they canquickly get up to steam plotting in python. From a developer'sperspective, having a fixed user interface (the pylab interface) hasbeen very useful, because the guts of the code base can be redesignedwithout affecting user code.
The Matplotlib code is conceptually divided into three parts: thepylab interface is the set of functions provided bypylab which allow the user to create plots with codequite similar to MATLAB figure generating code(Pyplot tutorial). TheMatplotlib frontend orMatplotlibAPI is the set of classes that do the heavy lifting, creating andmanaging figures, text, lines, plots and so on(Artist tutorial). This is an abstract interface that knowsnothing about output. Thebackends are device-dependent drawingdevices, aka renderers, that transform the frontend representation tohardcopy or a display device (What is a backend?). Examplebackends: PS createsPostScript® hardcopy, SVGcreatesScalable Vector Graphicshardcopy, Agg creates PNG output using the high qualityAnti-GrainGeometrylibrary that ships with Matplotlib, GTK embeds Matplotlib in aGtk+application, GTKAgg uses the Anti-Grain renderer to create a figureand embed it in a Gtk+ application, and so on forPDF,WxWidgets,Tkinter, etc.
Matplotlib is used by many people in many different contexts. Somepeople want to automatically generate PostScript files to sendto a printer or publishers. Others deploy Matplotlib on a webapplication server to generate PNG output for inclusion indynamically-generated web pages. Some use Matplotlib interactivelyfrom the Python shell in Tkinter on Windows. My primary use is toembed Matplotlib in a Gtk+ EEG application that runs on Windows, Linuxand Macintosh OS X.
Matplotlib's original logo (2003 -- 2008).
Matplotlib logo (2008 - 2015).
