@@ -5044,7 +5044,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5044
5044
that the data fit in the axes. In general, this will result in
5045
5045
non-square pixels.
5046
5046
5047
- Defaults to :rc:`image.aspect`.
5047
+ If not given, use :rc:`image.aspect` (default: 'equal') .
5048
5048
5049
5049
interpolation : str, optional
5050
5050
The interpolation method used. If *None*
@@ -7290,64 +7290,88 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
7290
7290
7291
7291
return spec , freqs , t , im
7292
7292
7293
+ @docstring .dedent_interpd
7293
7294
def spy (self , Z , precision = 0 , marker = None , markersize = None ,
7294
7295
aspect = 'equal' , origin = "upper" , ** kwargs ):
7295
7296
"""
7296
- Plot the sparsity pattern on a 2-D array.
7297
+ Plot the sparsity pattern of a 2D array.
7298
+
7299
+ This visualizes the non-zero values of the array.
7300
+
7301
+ Two plotting styles are available: image and marker. Both
7302
+ are available for full arrays, but only the marker style
7303
+ works for `scipy.sparse.spmatrix` instances.
7297
7304
7298
- ``spy(Z)`` plots the sparsity pattern of the 2-D array *Z*.
7305
+ **Image style**
7306
+
7307
+ If *marker* and *markersize* are *None*, `~.Axes.imshow` is used. Any
7308
+ extra remaining kwargs are passed to this method.
7309
+
7310
+ **Marker style**
7311
+
7312
+ If *Z* is a `scipy.sparse.spmatrix` or *marker* or *markersize* are
7313
+ *None*, a `~matplotlib.lines.Line2D` object will be returned with
7314
+ the value of marker determining the marker type, and any
7315
+ remaining kwargs passed to `~.Axes.plot`.
7299
7316
7300
7317
Parameters
7301
7318
----------
7302
-
7303
- Z : sparse array (n, m)
7319
+ Z : array-like (M, N)
7304
7320
The array to be plotted.
7305
7321
7306
- precision : float, optional, default: 0
7307
- If *precision* is 0, any non-zero value will be plotted; else ,
7322
+ precision : float or 'present' , optional, default: 0
7323
+ If *precision* is 0, any non-zero value will be plotted. Otherwise ,
7308
7324
values of :math:`|Z| > precision` will be plotted.
7309
7325
7310
- For :class:`scipy.sparse.spmatrix` instances, there is a special
7311
- case: if *precision* is 'present', any value present in the array
7326
+ For :class:`scipy.sparse.spmatrix` instances, you can also
7327
+ pass 'present'. In this case any value present in the array
7312
7328
will be plotted, even if it is identically zero.
7313
7329
7314
- origin : [" upper", " lower"] , optional, default: "upper"
7330
+ origin : {' upper', ' lower'} , optional
7315
7331
Place the [0,0] index of the array in the upper left or lower left
7316
- corner of the axes.
7332
+ corner of the axes. The convention 'upper' is typically used for
7333
+ matrices and images.
7334
+ If not given, :rc:`image.origin` is used, defaulting to 'upper'.
7335
+
7317
7336
7318
- aspect : ['auto' | 'equal' | scalar], optional, default: "equal"
7337
+ aspect : {'equal', 'auto', None} or float, optional
7338
+ Controls the aspect ratio of the axes. The aspect is of particular
7339
+ relevance for images since it may distort the image, i.e. pixel
7340
+ will not be square.
7319
7341
7320
- If 'equal', and `extent` is None, changes the axes aspect ratio to
7321
- match that of the image. If `extent` is not `None`, the axes
7322
- aspect ratio is changed to match that of the extent.
7342
+ This parameter is a shortcut for explicitly calling
7343
+ `.Axes.set_aspect`. See there for further details.
7323
7344
7345
+ - 'equal': Ensures an aspect ratio of 1. Pixels will be square.
7346
+ - 'auto': The axes is kept fixed and the aspect is adjusted so
7347
+ that the data fit in the axes. In general, this will result in
7348
+ non-square pixels.
7349
+ - *None*: Use :rc:`image.aspect` (default: 'equal').
7324
7350
7325
- If 'auto', changes the image aspect ratio to match that of the
7326
- axes.
7351
+ Default: 'equal'
7327
7352
7328
- If None, default to rc ``image.aspect`` value.
7353
+ Returns
7354
+ -------
7355
+ ret : `~matplotlib.image.AxesImage` or `.Line2D`
7356
+ The return type depends on the plotting style (see above).
7329
7357
7330
- Two plotting styles are available: image or marker. Both
7331
- are available for full arrays, but only the marker style
7332
- works for :class:`scipy.sparse.spmatrix` instances.
7358
+ Other Parameters
7359
+ ----------------
7360
+ **kwargs
7361
+ The supported additional parameters depend on the plotting style.
7333
7362
7334
- If *marker* and *markersize* are *None*, an image will be
7335
- returned and any remaining kwargs are passed to
7336
- :func:`~matplotlib.pyplot.imshow`; else, a
7337
- :class:`~matplotlib.lines.Line2D` object will be returned with
7338
- the value of marker determining the marker type, and any
7339
- remaining kwargs passed to the
7340
- :meth:`~matplotlib.axes.Axes.plot` method.
7363
+ For the image style, you can pass the following additional
7364
+ parameters of `~.Axes.imshow`:
7341
7365
7342
- If *marker* and *markersize* are *None*, useful kwargs include:
7366
+ - *cmap*
7367
+ - *alpha*
7368
+ - *url*
7369
+ - any `.Artist` properties (passed on to the `.AxesImage`)
7343
7370
7344
- * *cmap*
7345
- * *alpha*
7371
+ For the marker style, you can pass any `.Line2D` property except
7372
+ for *linestyle*:
7346
7373
7347
- See also
7348
- --------
7349
- imshow : for image options.
7350
- plot : for plotting options
7374
+ %(Line2D)s
7351
7375
"""
7352
7376
if marker is None and markersize is None and hasattr (Z , 'tocoo' ):
7353
7377
marker = 's'
0 commit comments