Barcode Layout

John Hunter jdhunter at
Mon Aug 9 15:18:09 CEST 2004

>>>>> "Aaron" == Aaron Bingham <bingham at> 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
    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.  


More information about the Python-list mailing list