Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > a44f8c7e78ee9c5838c1fb080c9e7630 > files > 1372

python-matplotlib-doc-1.1.1-1mdv2010.1.noarch.rpm

.. _pylab_examples-matshow:

pylab_examples example code: matshow.py
=======================================



.. plot:: /home/mandrake/rpm/BUILD/matplotlib-1.1.1/doc/mpl_examples/pylab_examples/matshow.py

::

    #!/usr/bin/env python
    """Simple matshow() example."""
    
    from matplotlib.pylab import *
    
    def samplemat(dims):
        """Make a matrix with all zeros and increasing elements on the diagonal"""
        aa = zeros(dims)
        for i in range(min(dims)):
            aa[i,i] = i
        return aa
    
    # Make a few matrices of strange sizes
    dimlist = [(12,12),(128,64),(64,512),(1024,128)]
    
    for d in dimlist:
        matshow(samplemat(d))
    
    # Display a random matrix with a specified figure number and a grayscale colormap
    matshow(rand(64,64),fignum=100,cmap=cm.gray)
    
    show()
    

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