Barcode Layout

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Aug 9 09:18:09 EDT 2004


>>>>> "Aaron" == Aaron Bingham <bingham at cenix-bioscience.com> writes:

    Aaron> One thing about piddle that's a good fit for our needs is
    Aaron> that we can add methods to the canvases e.g. drawBarcode()
    Aaron> just by adding that method to our backends.  Is there any
    Aaron> easy way to add such high-level drawing commands in
    Aaron> matlibplot that are passed down to the backend level?

It is certainly possible - it is easy to access the figure canvas and
then call canvas.whatever().  Here is a brief example

    import matplotlib
    matplotlib.use('MyBackend')
    from matplotlib.matlab import *

    # issue some plot commands; these will render to your backend
    plot(blah, blah)

    # this is the MyBackend canvas, which derives from
    # matplotlib.backend_bases.FigureCanvas 
    canvas = get_current_fig_manager().canvas  
    canvas.my_special_method()  # do some custom rendering

Whether this is desirable is another question, because then the output
will be backend specific.  I would encourage you, where possible, to
design the barcodes using matplotlib primitives in a function or
class, and then any backend will render them the same.  

JDH





More information about the Python-list mailing list