Sophie

Sophie

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

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

.. _pylab_examples-spy_demos:

pylab_examples example code: spy_demos.py
=========================================



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

::

    """
    Plot the sparsity pattern of arrays
    """
    
    from matplotlib.pyplot import figure, show
    import numpy
    
    fig = figure()
    ax1 = fig.add_subplot(221)
    ax2 = fig.add_subplot(222)
    ax3 = fig.add_subplot(223)
    ax4 = fig.add_subplot(224)
    
    x = numpy.random.randn(20,20)
    x[5] = 0.
    x[:,12] = 0.
    
    ax1.spy(x, markersize=5)
    ax2.spy(x, precision=0.1, markersize=5)
    
    ax3.spy(x)
    ax4.spy(x, precision=0.1)
    
    show()
    

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