22Introduction
33************
44
5- matplotlib is a library for making 2D plots of arrays in python.
6- Although it has its origins in emulating the MATLAB™ graphics
7- commands, it does not require MATLAB™, and can be used in a pythonic,
8- object oriented way. Although matplotlib is written primarily in pure
9- python, it makes heavy use of NumPy and other extension
5+ matplotlib is a library for making 2D plots of arrays in `Python
6+ <http://www.python.org>`_. Although it has its origins in emulating
7+ the `MATLAB™ <http://www.mathworks.com>`_ graphics commands, it does
8+ not require MATLAB™, and can be used in a Pythonic, object oriented
9+ way. Although matplotlib is written primarily in pure Python, it
10+ makes heavy use of `NumPy <http://www.numpy.org>`_ and other extension
1011code to provide good performance even for large arrays.
1112
1213matplotlib is designed with the philosophy that you should be able to
1314create simple plots with just a few commands, or just one! If you
1415want to see a histogram of your data, you shouldn't need to
15- instantiate objects, call methods, set properties, and so it ; it
16+ instantiate objects, call methods, set properties, and so on ; it
1617should just work.
1718
1819For years, I used to use MATLAB™ exclusively for data analysis and
@@ -22,67 +23,71 @@ applications to interact with my data, and developed and EEG analysis
2223application in MATLAB™. As the application grew in complexity,
2324interacting with databases, http servers, manipulating complex data
2425structures, I began to strain against the limitations of MATLAB™ as a
25- programming language, and decided to start over in python . python
26+ programming language, and decided to start over in Python . Python
2627more than makes up for all of matlab's deficiencies as a programming
2728language, but I was having difficulty finding a 2D plotting package
28- (for 3D VTK more than exceeds all of my needs).
29+ (for 3D ` VTK <http://www.vtk.org/>`_) more than exceeds all of my needs).
2930
30- When I went searching for a python plotting package, I had several
31+ When I went searching for a Python plotting package, I had several
3132requirements:
3233
3334* Plots should look great - publication quality. One important
34- requirement for me is that the text looks good (antialiased, etc)
35+ requirement for me is that the text looks good (antialiased, etc. )
3536
3637* Postscript output for inclusion with TeX documents
37-
38+
3839* Embeddable in a graphical user interface for application
3940 development
40-
41+
4142* Code should be easy enough that I can understand it and extend
42- it.
43+ it
4344
44- * Making plots should be easy.
45+ * Making plots should be easy
4546
4647Finding no package that suited me just right, I did what any
47- self-respecting python programmer would do: rolled up my sleeves and
48+ self-respecting Python programmer would do: rolled up my sleeves and
4849dived in. Not having any real experience with computer graphics, I
4950decided to emulate MATLAB™'s plotting capabilities because that is
5051something MATLAB™ does very well. This had the added advantage that
51- many people have a lot of MATLAB™ experience, and thus they can quickly
52- get up to steam plotting in python. From a developer's perspective,
53- having a fixed user interface (the pylab interface) has
52+ many people have a lot of MATLAB™ experience, and thus they can
53+ quickly get up to steam plotting in python. From a developer's
54+ perspective, having a fixed user interface (the pylab interface) has
5455been very useful, because the guts of the code base can be redesigned
5556without affecting user code.
5657
5758The matplotlib code is conceptually divided into three parts: the
5859*pylab interface* is the set of functions provided by
59- :mod:`matplotlib.pylab` which allow the user to create plots with
60- code quite similar to MATLAB™ figure generating code. The
61- *matplotlib frontend* or *matplotlib API* is the set of
62- classes that do the heavy lifting, creating and managing figures, text,
63- lines, plots and so on. This is an abstract interface that knows
64- nothing about output. The *backends* are device dependent
65- drawing devices, aka renderers, that transform the frontend
66- representation to hardcopy or a display device. Example backends: PS
67- creates postscript hardcopy, SVG creates scalar vector graphics
68- hardcopy, Agg creates PNG output using the high quality antigrain
69- library that ships with matplotlib --- http://antigrain.com, GTK
70- embeds matplotlib in a GTK application, GTKAgg uses the antigrain
71- renderer to create a figure and embed it a GTK application, and so on
72- for WX, Tkinter, FLTK...
60+ :mod:`matplotlib.pylab` which allow the user to create plots with code
61+ quite similar to MATLAB™ figure generating code. The *matplotlib
62+ frontend* or *matplotlib API* is the set of classes that do the heavy
63+ lifting, creating and managing figures, text, lines, plots and so on.
64+ This is an abstract interface that knows nothing about output. The
65+ *backends* are device dependent drawing devices, aka renderers, that
66+ transform the frontend representation to hardcopy or a display device.
67+ Example backends: PS creates `PostScript®
68+ <http://http://www.adobe.com/products/postscript/>`_ hardcopy, SVG
69+ creates `Scalable Vector Graphics <http://www.w3.org/Graphics/SVG/>`_
70+ hardcopy, Agg creates PNG output using the high quality `Anti-Grain
71+ Geometry <http://www.antigrain.com>`_ library that ships with
72+ matplotlib, GTK embeds matplotlib in a `Gtk+ <http://www.gtk.org/>`_
73+ application, GTKAgg uses the Anti-Grain renderer to create a figure
74+ and embed it a Gtk+ application, and so on for `PDF
75+ <http://www.adobe.com/products/acrobat/adobepdf.html>`_, `WxWidgets
76+ <http://www.wxpython.org/>`_, `Tkinter
77+ <http://docs.python.org/lib/module-Tkinter.html>`_ etc.
7378
7479matplotlib is used by many people in many different contexts. Some
75- people want to automatically generate postscript files to send to a
80+ people want to automatically generate PostScript® files to send to a
7681printer or publishers. Others deploy matplotlib on a web application
77- server to generate PNG output for inclusion in dynamically generated
78- web pages. Some use matplotlib interactively from the python shell in
79- Tkinter on windows . My primary use is to embed matplotlib in a GTK
80- EEG application that runs on windows, linux and OS X.
82+ server to generate PNG output for inclusion in dynamically- generated
83+ web pages. Some use matplotlib interactively from the Python shell in
84+ Tkinter on Windows® . My primary use is to embed matplotlib in a Gtk+
85+ EEG application that runs on Windows, Linux and Macintosh OS X.
8186
8287Because there are so many ways people want to use a plotting library,
8388there is a certain amount of complexity inherent in configuring the
84- library so that it will work naturally the way you want it to. Before
85- diving into these details, let's first explore matplotlib's simplicity
89+ library so that it will work naturally the way you want it to. Before
90+ diving into these details, let's first explore matplotlib's simplicity
8691by comparing a typical matplotlib script with its analog in MATLAB™.
8792
88- --- JDH
93+ --- JDH
0 commit comments