@@ -144,148 +144,6 @@ setupegg.py develop` command again to compile them.
144
144
There is more information on :ref: `using git <using-git >` in
145
145
the developer docs.
146
146
147
- Backends
148
- ========
149
-
150
- .. _what-is-a-backend :
151
-
152
- What is a backend?
153
- ------------------
154
-
155
- A lot of documentation on the website and in the mailing lists refers
156
- to the "backend" and many new users are confused by this term.
157
- matplotlib targets many different use cases and output formats. Some
158
- people use matplotlib interactively from the python shell and have
159
- plotting windows pop up when they type commands. Some people embed
160
- matplotlib into graphical user interfaces like wxpython or pygtk to
161
- build rich applications. Others use matplotlib in batch scripts to
162
- generate postscript images from some numerical simulations, and still
163
- others in web application servers to dynamically serve up graphs.
164
-
165
- To support all of these use cases, matplotlib can target different
166
- outputs, and each of these capabilities is called a backend; the
167
- "frontend" is the user facing code, ie the plotting code, whereas the
168
- "backend" does all the hard work behind-the-scenes to make the
169
- figure. There are two types of backends: user interface backends (for
170
- use in pygtk, wxpython, tkinter, qt, macosx, or fltk) and hardcopy backends to
171
- make image files (PNG, SVG, PDF, PS).
172
-
173
- There are a two primary ways to configure your backend. One is to set
174
- the ``backend `` parameter in your ``matplotlibrc `` file (see
175
- :ref: `customizing-matplotlib `)::
176
-
177
- backend : WXAgg # use wxpython with antigrain (agg) rendering
178
-
179
- The other is to use the matplotlib :func: `~matplotlib.use ` directive::
180
-
181
- import matplotlib
182
- matplotlib.use('PS') # generate postscript output by default
183
-
184
- If you use the ``use `` directive, this must be done before importing
185
- :mod: `matplotlib.pyplot ` or :mod: `matplotlib.pylab `.
186
-
187
- If you are unsure what to do, and just want to get coding, just set
188
- your backend to ``TkAgg ``. This will do the right thing for most
189
- users. It gives you the option of running your scripts in batch or
190
- working interactively from the python shell, with the least amount of
191
- hassles, and is smart enough to do the right thing when you ask for
192
- postscript, or pdf, or other image formats.
193
-
194
- If however, you want to write graphical user interfaces, or a web
195
- application server (:ref: `howto-webapp `), or need a better
196
- understanding of what is going on, read on. To make things a little
197
- more customizable for graphical user interfaces, matplotlib separates
198
- the concept of the renderer (the thing that actually does the drawing)
199
- from the canvas (the place where the drawing goes). The canonical
200
- renderer for user interfaces is ``Agg `` which uses the `Anti-Grain
201
- Geometry `_ C++ library to make a raster (pixel) image of the figure.
202
- All of the user interfaces can be used with agg rendering, eg
203
- ``WXAgg ``, ``GTKAgg ``, ``QTAgg ``, ``TkAgg ``, ``CocoaAgg ``. In
204
- addition, some of the user interfaces support other rendering engines.
205
- For example, with GTK, you can also select GDK rendering (backend
206
- ``GTK ``) or Cairo rendering (backend ``GTKCairo ``).
207
-
208
- For the rendering engines, one can also distinguish between `vector
209
- <http://en.wikipedia.org/wiki/Vector_graphics> `_ or `raster
210
- <http://en.wikipedia.org/wiki/Raster_graphics> `_ renderers. Vector
211
- graphics languages issue drawing commands like "draw a line from this
212
- point to this point" and hence are scale free, and raster backends
213
- generate a pixel representation of the line whose accuracy depends on a
214
- DPI setting.
215
-
216
- Here is a summary of the matplotlib renderers (there is an eponymous
217
- backed for each):
218
-
219
- ============= ============ ================================================
220
- Renderer Filetypes Description
221
- ============= ============ ================================================
222
- :term: `AGG ` :term: `png ` :term: `raster graphics ` -- high quality images
223
- using the `Anti-Grain Geometry `_ engine
224
- PS :term: `ps ` :term: `vector graphics ` -- Postscript _ output
225
- :term: `eps `
226
- PDF :term: `pdf ` :term: `vector graphics ` --
227
- `Portable Document Format `_
228
- SVG :term: `svg ` :term: `vector graphics ` --
229
- `Scalable Vector Graphics `_
230
- :term: `Cairo ` :term: `png ` :term: `vector graphics ` --
231
- :term: `ps ` `Cairo graphics `_
232
- :term: `pdf `
233
- :term: `svg `
234
- ...
235
- :term: `GDK ` :term: `png ` :term: `raster graphics ` --
236
- :term: `jpg ` the `Gimp Drawing Kit `_
237
- :term: `tiff `
238
- ...
239
- ============= ============ ================================================
240
-
241
- And here are the user interfaces and renderer combinations supported:
242
-
243
- ============ ================================================================
244
- Backend Description
245
- ============ ================================================================
246
- GTKAgg Agg rendering to a :term: `GTK ` canvas (requires PyGTK _)
247
- GTK GDK rendering to a :term: `GTK ` canvas (not recommended)
248
- (requires PyGTK _)
249
- GTKCairo Cairo rendering to a :term: `GTK ` Canvas (requires PyGTK _)
250
- WXAgg Agg rendering to to a :term: `wxWidgets ` canvas
251
- (requires wxPython _)
252
- WX Native :term: `wxWidgets ` drawing to a :term: `wxWidgets ` Canvas
253
- (not recommended) (requires wxPython _)
254
- TkAgg Agg rendering to a :term: `Tk ` canvas (requires TkInter _)
255
- QtAgg Agg rendering to a :term: `Qt ` canvas (requires PyQt _)
256
- Qt4Agg Agg rendering to a :term: `Qt4 ` canvas (requires PyQt4 _)
257
- FLTKAgg Agg rendering to a :term: `FLTK ` canvas (requires pyFLTK _)
258
- macosx Cocoa rendering in OSX windows
259
- ============ ================================================================
260
-
261
- .. _`Anti-Grain Geometry` : http://www.antigrain.com/
262
- .. _Postscript : http://en.wikipedia.org/wiki/PostScript
263
- .. _`Portable Document Format` : http://en.wikipedia.org/wiki/Portable_Document_Format
264
- .. _`Scalable Vector Graphics` : http://en.wikipedia.org/wiki/Scalable_Vector_Graphics
265
- .. _`Cairo graphics` : http://en.wikipedia.org/wiki/Cairo_(graphics)
266
- .. _`Gimp Drawing Kit` : http://en.wikipedia.org/wiki/GDK
267
- .. _PyGTK : http://www.pygtk.org
268
- .. _wxPython : http://www.wxpython.org/
269
- .. _TkInter : http://wiki.python.org/moin/TkInter
270
- .. _PyQt : http://www.riverbankcomputing.co.uk/software/pyqt/intro
271
- .. _PyQt4 : http://www.riverbankcomputing.co.uk/software/pyqt/intro
272
- .. _pyFLTK : http://pyfltk.sourceforge.net
273
-
274
-
275
- .. _pygtk-2.4 :
276
-
277
- Compile matplotlib with PyGTK-2.4
278
- -------------------------------------------
279
-
280
- There is a `bug in PyGTK-2.4 `_. You need to edit :file: `pygobject.h `
281
- to add the :c:macro: `G_BEGIN_DECLS ` and :c:macro: `G_END_DECLS ` macros,
282
- and rename :c:data: `typename ` parameter to :c:data: `typename_ `::
283
-
284
- - const char *typename,
285
- + const char *typename_,
286
-
287
- .. _`bug in PyGTK-2.4` : http://bugzilla.gnome.org/show_bug.cgi?id=155304
288
-
289
147
290
148
OS-X questions
291
149
==============
0 commit comments