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