/
usr
/
lib64
/
python2.6
/
site-packages
/
matplotlib
/
backends
/
/usr/lib64/python2.6/site-packages/matplotlib/backends
mkdir
upload
Name
Size
Mode
Actions
Matplotlib.nib/
-
0755
rm
backend_agg.py
13037
0644
edit
dl
rm
backend_agg.pyc
14578
0644
edit
dl
rm
backend_agg.pyo
13367
0644
edit
dl
rm
backend_cairo.py
16493
0644
edit
dl
rm
backend_cairo.pyc
18270
0644
edit
dl
rm
backend_cairo.pyo
18270
0644
edit
dl
rm
backend_cocoaagg.py
8988
0644
edit
dl
rm
backend_cocoaagg.pyc
11930
0644
edit
dl
rm
backend_cocoaagg.pyo
11930
0644
edit
dl
rm
backend_emf.py
22336
0644
edit
dl
rm
backend_emf.pyc
25220
0644
edit
dl
rm
backend_emf.pyo
25220
0644
edit
dl
rm
backend_fltkagg.py
20852
0644
edit
dl
rm
backend_fltkagg.pyc
26631
0644
edit
dl
rm
backend_fltkagg.pyo
26631
0644
edit
dl
rm
backend_gdk.py
15968
0644
edit
dl
rm
backend_gdk.pyc
17157
0644
edit
dl
rm
backend_gdk.pyo
17157
0644
edit
dl
rm
backend_gtk.py
40707
0644
edit
dl
rm
backend_gtk.pyc
45101
0644
edit
dl
rm
backend_gtk.pyo
45101
0644
edit
dl
rm
backend_gtkagg.py
4134
0644
edit
dl
rm
backend_gtkagg.pyc
5088
0644
edit
dl
rm
backend_gtkagg.pyo
5088
0644
edit
dl
rm
backend_gtkcairo.py
2079
0644
edit
dl
rm
backend_gtkcairo.pyc
3740
0644
edit
dl
rm
backend_gtkcairo.pyo
3740
0644
edit
dl
rm
backend_macosx.py
14644
0644
edit
dl
rm
backend_macosx.pyc
20536
0644
edit
dl
rm
backend_macosx.pyo
20439
0644
edit
dl
rm
backend_mixed.py
5166
0644
edit
dl
rm
backend_mixed.pyc
4844
0644
edit
dl
rm
backend_mixed.pyo
4773
0644
edit
dl
rm
backend_pdf.py
77716
0644
edit
dl
rm
backend_pdf.pyc
66626
0644
edit
dl
rm
backend_pdf.pyo
66508
0644
edit
dl
rm
backend_ps.py
51444
0644
edit
dl
rm
backend_ps.pyc
48055
0644
edit
dl
rm
backend_ps.pyo
48055
0644
edit
dl
rm
backend_qt.py
16846
0644
edit
dl
rm
backend_qt.pyc
21065
0644
edit
dl
rm
backend_qt.pyo
21065
0644
edit
dl
rm
backend_qt4.py
21006
0644
edit
dl
rm
backend_qt4.pyc
24697
0644
edit
dl
rm
backend_qt4.pyo
24697
0644
edit
dl
rm
backend_qt4agg.py
4799
0644
edit
dl
rm
backend_qt4agg.pyc
5883
0644
edit
dl
rm
backend_qt4agg.pyo
5883
0644
edit
dl
rm
backend_qtagg.py
4972
0644
edit
dl
rm
backend_qtagg.pyc
6014
0644
edit
dl
rm
backend_qtagg.pyo
6014
0644
edit
dl
rm
backend_svg.py
25951
0644
edit
dl
rm
backend_svg.pyc
24476
0644
edit
dl
rm
backend_svg.pyo
24368
0644
edit
dl
rm
backend_template.py
8806
0644
edit
dl
rm
backend_template.pyc
9385
0644
edit
dl
rm
backend_template.pyo
9385
0644
edit
dl
rm
backend_wx.py
78921
0644
edit
dl
rm
backend_wx.pyc
79007
0644
edit
dl
rm
backend_wx.pyo
78931
0644
edit
dl
rm
backend_wxagg.py
9099
0644
edit
dl
rm
backend_wxagg.pyc
9363
0644
edit
dl
rm
backend_wxagg.pyo
9363
0644
edit
dl
rm
_backend_agg.so
430792
0775
edit
dl
rm
_backend_gdk.so
8168
0775
edit
dl
rm
_gtkagg.so
143816
0775
edit
dl
rm
__init__.py
2225
0644
edit
dl
rm
__init__.pyc
2120
0644
edit
dl
rm
__init__.pyo
2120
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_template.py
(8806B)
""" 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 """ from __future__ import division import matplotlib from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase from matplotlib.figure import Figure from matplotlib.transforms import Bbox class RendererTemplate(RendererBase): """ 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. """ def __init__(self, dpi): self.dpi = dpi def draw_path(self, gc, path, transform, rgbFace=None): pass # draw_markers is optional, and we get more correct relative # timings by leaving it out. backend implementers concerned with # performance will probably want to implement it # def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): # pass # draw_path_collection is optional, and we get more correct # relative timings by leaving it out. backend implementers concerned with # performance will probably want to implement it # def draw_path_collection(self, master_transform, cliprect, clippath, # clippath_trans, paths, all_transforms, offsets, # offsetTrans, facecolors, edgecolors, linewidths, # linestyles, antialiaseds): # pass # draw_quad_mesh is optional, and we get more correct # relative timings by leaving it out. backend implementers concerned with # performance will probably want to implement it # def draw_quad_mesh(self, master_transform, cliprect, clippath, # clippath_trans, meshWidth, meshHeight, coordinates, # offsets, offsetTrans, facecolors, antialiased, # showedges): # pass def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): pass def draw_text(self, gc, x, y, s, prop, angle, ismath=False): pass def flipy(self): return True def get_canvas_width_height(self): return 100, 100 def get_text_width_height_descent(self, s, prop, ismath): return 1, 1, 1 def new_gc(self): return GraphicsContextTemplate() def points_to_pixels(self, points): # if backend doesn't have dpi, eg, postscript or svg return points # elif backend assumes a value for pixels_per_inch #return points/72.0 * self.dpi.get() * pixels_per_inch/72.0 # else #return points/72.0 * self.dpi.get() class GraphicsContextTemplate(GraphicsContextBase): """ 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. """ pass ######################################################################## # # The following functions and classes are for pylab and implement # window/figure managers, etc... # ######################################################################## def draw_if_interactive(): """ For image backends - is not required For GUI backends - this should be overriden if drawing should be done in interactive python mode """ pass def show(): """ For image backends - is not required For GUI backends - show() is usually the last line of a pylab script and tells the backend that it is time to draw. In interactive mode, this may be a do nothing func. See the GTK backend for an example of how to handle interactive versus batch mode """ for manager in Gcf.get_all_fig_managers(): # do something to display the GUI pass def new_figure_manager(num, *args, **kwargs): """ Create a new figure manager instance """ # if a main-level app must be created, this is the usual place to # do it -- see backend_wx, backend_wxagg and backend_tkagg for # examples. Not all GUIs require explicit instantiation of a # main-level app (egg backend_gtk, backend_gtkagg) for pylab FigureClass = kwargs.pop('FigureClass', Figure) thisFig = FigureClass(*args, **kwargs) canvas = FigureCanvasTemplate(thisFig) manager = FigureManagerTemplate(canvas, num) return manager class FigureCanvasTemplate(FigureCanvasBase): """ The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc... Public attribute figure - A Figure instance Note GUI templates will want to connect events for button presses, mouse movements and key presses to functions that call the base class methods button_press_event, button_release_event, motion_notify_event, key_press_event, and key_release_event. See, eg backend_gtk.py, backend_wx.py and backend_tkagg.py """ def draw(self): """ Draw the figure using the renderer """ renderer = RendererTemplate(self.figure.dpi) self.figure.draw(renderer) # You should provide a print_xxx function for every file format # you can write. # If the file type is not in the base set of filetypes, # you should add it to the class-scope filetypes dictionary as follows: filetypes = FigureCanvasBase.filetypes.copy() filetypes['foo'] = 'My magic Foo format' def print_foo(self, filename, *args, **kwargs): """ Write out format foo. The dpi, facecolor and edgecolor are restored to their original values after this call, so you don't need to save and restore them. """ pass def get_default_filetype(self): return 'foo' class FigureManagerTemplate(FigureManagerBase): """ Wrap everything up into a window for the pylab interface For non interactive backends, the base class does all the work """ pass ######################################################################## # # Now just provide the standard names that backend.__init__ is expecting # ######################################################################## FigureManager = FigureManagerTemplate
Save
cmd:
run