Ñò 8”tJc @ sñ d Z d d k l Z d d k Z d d k l Z d d k l Z l Z l Z l Z d d k l Z d d k l Z d e f d „ ƒ YZ d e f d „ ƒ YZ d „ Z d „ Z d „ Z d e f d „ ƒ YZ d e f d „ ƒ YZ e Z d S( s© This is a fully functional do nothing backend to provide a template to backend writers. It is fully functional in that you can select it as a backend with import matplotlib matplotlib.use('Template') and your matplotlib scripts will (should!) run without error, though no output is produced. This provides a nice starting point for backend writers because you can selectively implement methods (draw_rectangle, draw_lines, etc...) and slowly see your figure come to life w/o having to have a full blown implementation before getting any results. Copy this to backend_xxx.py and replace all instances of 'template' with 'xxx'. Then implement the class methods and functions below, and add 'xxx' to the switchyard in matplotlib/backends/__init__.py and 'xxx' to the backends list in the validate_backend methon in matplotlib/__init__.py and you're off. You can use your backend with:: import matplotlib matplotlib.use('xxx') from pylab import * plot([1,2,3]) show() matplotlib also supports external backends, so you can place you can use any module in your PYTHONPATH with the syntax:: import matplotlib matplotlib.use('module://my_backend') where my_backend.py is your module name. Thus syntax is also recognized in the rc file and in the -d argument in pylab, eg:: python simple_plot.py -dmodule://my_backend The files that are most relevant to backend_writers are matplotlib/backends/backend_your_backend.py matplotlib/backend_bases.py matplotlib/backends/__init__.py matplotlib/__init__.py matplotlib/_pylab_helpers.py Naming Conventions * classes Upper or MixedUpperCase * varables lower or lowerUpper * functions lower or underscore_separated iÿÿÿÿ( t divisionN( t Gcf( t RendererBaset GraphicsContextBaset FigureManagerBaset FigureCanvasBase( t Figure( t Bboxt RendererTemplatec B sk e Z d Z d „ Z d d „ Z d d d „ Z e d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( sö The renderer handles drawing/rendering operations. This is a minimal do-nothing class that can be used to get started when writing a new backend. Refer to backend_bases.RendererBase for documentation of the classes methods. c C s | | _ d S( N( t dpi( t selfR ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt __init__K s c C s d S( N( ( R t gct patht transformt rgbFace( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt draw_pathN s c C s d S( N( ( R t xt yt imt bboxt clippatht clippath_trans( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt draw_imagei s c C s d S( N( ( R R R R t st propt anglet ismath( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt draw_textl s c C s t S( N( t True( R ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt flipyo s c C s d S( Nid ( id id ( ( R ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt get_canvas_width_heightr s c C s d S( Ni ( i i i ( ( R R R R ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt get_text_width_height_descentu s c C s t ƒ S( N( t GraphicsContextTemplate( R ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt new_gcx s c C s | S( N( ( R t points( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyt points_to_pixels{ s N( t __name__t __module__t __doc__R t NoneR R t FalseR R R R R" R$ ( ( ( sJ /usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.pyR C s R! c B s e Z d Z RS( sâ The graphics context provides the color, line styles, etc... See the gtk and postscript backends for examples of mapping the graphics context attributes (cap styles, join styles, line widths, colors) to a particular backend. In GTK this is done by wrapping a gtk.gdk.GC object and forwarding the appropriate calls to it using a dictionary mapping styles to gdk constants. In Postscript, all the work is done by the renderer, mapping line styles to postscript calls. If it's more appropriate to do the mapping at the renderer level (as in the postscript backend), you don't need to override any of the GC methods. If it's more appropriate to wrap an instance (as in the GTK backend) and do the mapping here, you'll need to override several of the setter methods. The base GraphicsContext stores colors as a RGB tuple on the unit interval, eg, (0.5, 0.0, 1.0). You may need to map this to colors appropriate for your backend. ( R% R&