Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > bf21b4394f4d7fa09e3626145d3315e0 > files > 414

python-matplotlib-doc-1.2.0-14.fc18.i686.rpm

.. _pylab_examples-legend_translucent:

pylab_examples example code: legend_translucent.py
==================================================



.. plot:: /builddir/build/BUILD/matplotlib-1.2.0/doc/mpl_examples/pylab_examples/legend_translucent.py

::

    #!/usr/bin/python
    #
    # Show how to add a translucent legend
    
    # import pyplot module
    import matplotlib.pyplot as plt
    
    # draw 2 crossing lines
    plt.plot([0,1], label='going up')
    plt.plot([1,0], label='going down')
    
    # add the legend in the middle of the plot
    leg = plt.legend(fancybox=True, loc='center')
    # set the alpha value of the legend: it will be translucent
    leg.get_frame().set_alpha(0.5)
    
    # show the plot
    plt.show()
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)