MCPcopy
hub / github.com/matplotlib/matplotlib / spy

Method spy

lib/matplotlib/axes/_axes.py:8674–8810  ·  view source on GitHub ↗

Plot the sparsity pattern of a 2D array. This visualizes the non-zero values of the array. Two plotting styles are available: image and marker. Both are available for full arrays, but only the marker style works for `scipy.sparse.spmatrix` instances.

(self, Z, precision=0, marker=None, markersize=None,
            aspect='equal', origin="upper", **kwargs)

Source from the content-addressed store, hash-verified

8672 @_api.make_keyword_only("3.10", "precision")
8673 @_docstring.interpd
8674 def spy(self, Z, precision=0, marker=None, markersize=None,
8675 aspect='equal', origin="upper", **kwargs):
8676 """
8677 Plot the sparsity pattern of a 2D array.
8678
8679 This visualizes the non-zero values of the array.
8680
8681 Two plotting styles are available: image and marker. Both
8682 are available for full arrays, but only the marker style
8683 works for `scipy.sparse.spmatrix` instances.
8684
8685 **Image style**
8686
8687 If *marker* and *markersize* are *None*, `~.Axes.imshow` is used. Any
8688 extra remaining keyword arguments are passed to this method.
8689
8690 **Marker style**
8691
8692 If *Z* is a `scipy.sparse.spmatrix` or *marker* or *markersize* are
8693 *None*, a `.Line2D` object will be returned with the value of marker
8694 determining the marker type, and any remaining keyword arguments
8695 passed to `~.Axes.plot`.
8696
8697 Parameters
8698 ----------
8699 Z : (M, N) array-like
8700 The array to be plotted.
8701
8702 precision : float or 'present', default: 0
8703 If *precision* is 0, any non-zero value will be plotted. Otherwise,
8704 values of :math:`|Z| > precision` will be plotted.
8705
8706 For `scipy.sparse.spmatrix` instances, you can also
8707 pass 'present'. In this case any value present in the array
8708 will be plotted, even if it is identically zero.
8709
8710 aspect : {'equal', 'auto', None} or float, default: 'equal'
8711 The aspect ratio of the Axes. This parameter is particularly
8712 relevant for images since it determines whether data pixels are
8713 square.
8714
8715 This parameter is a shortcut for explicitly calling
8716 `.Axes.set_aspect`. See there for further details.
8717
8718 - 'equal': Ensures an aspect ratio of 1. Pixels will be square.
8719 - 'auto': The Axes is kept fixed and the aspect is adjusted so
8720 that the data fit in the Axes. In general, this will result in
8721 non-square pixels.
8722 - *None*: Use :rc:`image.aspect`.
8723
8724 origin : {'upper', 'lower'}, default: :rc:`image.origin`
8725 Place the [0, 0] index of the array in the upper left or lower left
8726 corner of the Axes. The convention 'upper' is typically used for
8727 matrices and images.
8728
8729 Returns
8730 -------
8731 `~matplotlib.image.AxesImage` or `.Line2D`

Callers 5

spyFunction · 0.80
test_spyFunction · 0.80
test_spy_invalid_kwargsFunction · 0.80
test_spy_boxFunction · 0.80
spy_demos.pyFile · 0.80

Calls 10

imshowMethod · 0.95
add_lineMethod · 0.80
tick_topMethod · 0.80
tick_bottomMethod · 0.80
set_xlimMethod · 0.45
set_ylimMethod · 0.45
set_aspectMethod · 0.45
set_yMethod · 0.45
set_ticks_positionMethod · 0.45
set_major_locatorMethod · 0.45

Tested by 3

test_spyFunction · 0.64
test_spy_invalid_kwargsFunction · 0.64
test_spy_boxFunction · 0.64