@@ -167,8 +167,10 @@ outputs, and each of these capabilities is called a backend; the
167
167
"frontend" is the user facing code, ie the plotting code, whereas the
168
168
"backend" does all the hard work behind-the-scenes to make the
169
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).
170
+ use in pygtk, wxpython, tkinter, qt, macosx, or fltk; also
171
+ referred to as "interactive backends") and hardcopy backends to
172
+ make image files (PNG, SVG, PDF, PS; also referred to as "non-interactive
173
+ backends").
172
174
173
175
There are a two primary ways to configure your backend. One is to set
174
176
the ``backend `` parameter in your ``matplotlibrc `` file (see
@@ -184,23 +186,28 @@ The other is to use the matplotlib :func:`~matplotlib.use` directive::
184
186
If you use the ``use `` directive, this must be done before importing
185
187
:mod: `matplotlib.pyplot ` or :mod: `matplotlib.pylab `.
186
188
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.
189
+ .. note ::
190
+ Backend name specifications are not case-sensitive; e.g., 'GTKAgg'
191
+ and 'gtkagg' are equivalent.
192
+
193
+ With a typical installation of matplotlib, such as from a
194
+ binary installer or a linux distribution package, a good default
195
+ backend will already be set, allowing both interactive work and
196
+ plotting from scripts, with output to the screen and/or to
197
+ a file, so at least initially you will not need to use either of the
198
+ two methods given above.
193
199
194
- If however, you want to write graphical user interfaces, or a web
200
+ If, however, you want to write graphical user interfaces, or a web
195
201
application server (:ref: `howto-webapp `), or need a better
196
202
understanding of what is going on, read on. To make things a little
197
203
more customizable for graphical user interfaces, matplotlib separates
198
204
the concept of the renderer (the thing that actually does the drawing)
199
205
from the canvas (the place where the drawing goes). The canonical
200
206
renderer for user interfaces is ``Agg `` which uses the `Anti-Grain
201
207
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
208
+ All of the user interfaces except ``macosx `` can be used with
209
+ agg rendering, eg
210
+ ``WXAgg ``, ``GTKAgg ``, ``QT4Agg ``, ``TkAgg ``. In
204
211
addition, some of the user interfaces support other rendering engines.
205
212
For example, with GTK, you can also select GDK rendering (backend
206
213
``GTK ``) or Cairo rendering (backend ``GTKCairo ``).
@@ -214,7 +221,8 @@ generate a pixel representation of the line whose accuracy depends on a
214
221
DPI setting.
215
222
216
223
Here is a summary of the matplotlib renderers (there is an eponymous
217
- backed for each):
224
+ backed for each; these are *non-interactive backends *, capable of
225
+ writing to a file):
218
226
219
227
============= ============ ================================================
220
228
Renderer Filetypes Description
@@ -238,7 +246,10 @@ SVG :term:`svg` :term:`vector graphics` --
238
246
...
239
247
============= ============ ================================================
240
248
241
- And here are the user interfaces and renderer combinations supported:
249
+ And here are the user interfaces and renderer combinations supported;
250
+ these are *interactive backends *, capable of displaying to the screen
251
+ and of using appropriate renderers from the table above to write to
252
+ a file:
242
253
243
254
============ ================================================================
244
255
Backend Description
@@ -253,9 +264,14 @@ WX Native :term:`wxWidgets` drawing to a :term:`wxWidgets` Canvas
253
264
(not recommended) (requires wxPython _)
254
265
TkAgg Agg rendering to a :term: `Tk ` canvas (requires TkInter _)
255
266
QtAgg Agg rendering to a :term: `Qt ` canvas (requires PyQt _)
267
+ (not recommended; use Qt4Agg)
256
268
Qt4Agg Agg rendering to a :term: `Qt4 ` canvas (requires PyQt4 _)
257
269
FLTKAgg Agg rendering to a :term: `FLTK ` canvas (requires pyFLTK _)
270
+ (not widely used; consider TKAgg, GTKAgg, WXAgg, or
271
+ QT4Agg instead)
258
272
macosx Cocoa rendering in OSX windows
273
+ (presently lacks blocking show() behavior when matplotlib
274
+ is in non-interactive mode)
259
275
============ ================================================================
260
276
261
277
.. _`Anti-Grain Geometry` : http://www.antigrain.com/
@@ -272,21 +288,6 @@ macosx Cocoa rendering in OSX windows
272
288
.. _pyFLTK : http://pyfltk.sourceforge.net
273
289
274
290
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
281
- :file: `pygobject.h ` to add the :c:macro: `G_BEGIN_DECLS ` and :c:macro: `G_END_DECLS `
282
- macros, 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
-
290
291
OS-X questions
291
292
==============
292
293
0 commit comments