Sophie

Sophie

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

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

.. _pylab_examples-image_demo3:

pylab_examples example code: image_demo3.py
===========================================



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

::

    #!/usr/bin/env python
    from pylab import *
    try:
        from PIL import Image
    except ImportError:
        raise SystemExit("PIL must be installed to run this example")
    
    import matplotlib.cbook as cbook
    
    datafile = cbook.get_sample_data('lena.jpg')
    lena = Image.open(datafile)
    dpi = rcParams['figure.dpi']
    figsize = lena.size[0]/dpi, lena.size[1]/dpi
    
    figure(figsize=figsize)
    ax = axes([0,0,1,1], frameon=False)
    ax.set_axis_off()
    im = imshow(lena)
    
    show()
    
    

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