You are reading an old version of the documentation (v1.4.3). For the latest version see https://matplotlib.org/stable/

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates

matplotlib

Previous topic

pylab_examples example code: spine_placement_demo.py

Next topic

pylab_examples example code: stackplot_demo.py

This Page

pylab_examples example code: spy_demos.pyΒΆ

(Source code, png, hires.png, pdf)

../../_images/spy_demos.png
"""
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 Search examples)