@@ -196,82 +196,97 @@ def _dsplot(plotfunc):
196
196
197
197
ds : Dataset
198
198
x, y : str
199
- Variable names for x, y axis .
199
+ Variable names for the *x* and *y* grid positions .
200
200
u, v : str, optional
201
- Variable names for quiver or streamplot plots only
201
+ Variable names for the *u* and *v* velocities
202
+ (in *x* and *y* direction, respectively; quiver/streamplot plots only).
202
203
hue: str, optional
203
- Variable by which to color scattered points or arrows
204
- hue_style: str, optional
205
- Can be either 'discrete' (legend) or 'continuous' (color bar).
204
+ Variable by which to color scatter points or arrows.
205
+ hue_style: {'continuous', 'discrete'}, optional
206
+ How to use the ``hue`` variable:
207
+
208
+ - ``'continuous'`` -- continuous color scale
209
+ (default for numeric ``hue`` variables)
210
+ - ``'discrete'`` -- a color for each unique value, using the default color cycle
211
+ (default for non-numeric ``hue`` variables)
206
212
markersize: str, optional
207
- scatter only. Variable by which to vary size of scattered points.
208
- size_norm: optional
209
- Either None or 'Norm' instance to normalize the 'markersize' variable.
213
+ Variable by which to vary the size of scattered points (scatter plot only).
214
+ size_norm: matplotlib.colors.Normalize or tuple, optional
215
+ Used to normalize the ``markersize`` variable.
216
+ If a tuple is passed, the values will be passed to
217
+ :py:class:`matplotlib:matplotlib.colors.Normalize` as arguments.
218
+ Default: no normalization (``vmin=None``, ``vmax=None``, ``clip=False``).
210
219
scale: scalar, optional
211
220
Quiver only. Number of data units per arrow length unit.
212
221
Use this to control the length of the arrows: larger values lead to
213
- smaller arrows
214
- add_guide: bool, optional
215
- Add a guide that depends on hue_style
216
- - for "discrete", build a legend.
217
- This is the default for non-numeric `hue` variables.
218
- - for "continuous", build a colorbar
222
+ smaller arrows.
223
+ add_guide: bool, optional, default: True
224
+ Add a guide that depends on `` hue_style``:
225
+
226
+ - ``'continuous'`` -- build a colorbar
227
+ - ``'discrete'`` -- build a legend
219
228
row : str, optional
220
- If passed, make row faceted plots on this dimension name
229
+ If passed, make row faceted plots on this dimension name.
221
230
col : str, optional
222
- If passed, make column faceted plots on this dimension name
231
+ If passed, make column faceted plots on this dimension name.
223
232
col_wrap : int, optional
224
- Use together with ``col`` to wrap faceted plots
233
+ Use together with ``col`` to wrap faceted plots.
225
234
ax : matplotlib axes object, optional
226
- If None, uses the current axis . Not applicable when using facets.
235
+ If `` None``, use the current axes . Not applicable when using facets.
227
236
subplot_kws : dict, optional
228
- Dictionary of keyword arguments for matplotlib subplots. Only applies
229
- to FacetGrid plotting.
237
+ Dictionary of keyword arguments for Matplotlib subplots
238
+ (see :py:meth:`matplotlib:matplotlib.figure.Figure.add_subplot`).
239
+ Only applies to FacetGrid plotting.
230
240
aspect : scalar, optional
231
- Aspect ratio of plot, so that ``aspect * size`` gives the width in
241
+ Aspect ratio of plot, so that ``aspect * size`` gives the * width* in
232
242
inches. Only used if a ``size`` is provided.
233
243
size : scalar, optional
234
- If provided, create a new figure for the plot with the given size.
235
- Height (in inches) of each plot. See also: ``aspect``.
236
- norm : `` matplotlib.colors.Normalize`` instance , optional
237
- If the ``norm`` has vmin or vmax specified, the corresponding kwarg
238
- must be None.
244
+ If provided, create a new figure for the plot with the given size:
245
+ *height* (in inches) of each plot. See also: ``aspect``.
246
+ norm : matplotlib.colors.Normalize, optional
247
+ If ``norm`` has `` vmin`` or `` vmax`` specified, the corresponding
248
+ kwarg must be `` None`` .
239
249
vmin, vmax : float, optional
240
250
Values to anchor the colormap, otherwise they are inferred from the
241
251
data and other keyword arguments. When a diverging dataset is inferred,
242
252
setting one of these values will fix the other by symmetry around
243
253
``center``. Setting both values prevents use of a diverging colormap.
244
254
If discrete levels are provided as an explicit list, both of these
245
255
values are ignored.
246
- cmap : str or colormap, optional
256
+ cmap : matplotlib colormap name or colormap, optional
247
257
The mapping from data values to color space. Either a
248
- matplotlib colormap name or object. If not provided, this will
249
- be either ``viridis`` (if the function infers a sequential
250
- dataset) or ``RdBu_r`` (if the function infers a diverging
251
- dataset). When `Seaborn` is installed, ``cmap`` may also be a
252
- `seaborn` color palette. If ``cmap`` is seaborn color palette,
258
+ Matplotlib colormap name or object. If not provided, this will
259
+ be either ``'viridis'`` (if the function infers a sequential
260
+ dataset) or ``'RdBu_r'`` (if the function infers a diverging
261
+ dataset).
262
+ See :doc:`Choosing Colormaps in Matplotlib <matplotlib:tutorials/colors/colormaps>`
263
+ for more information.
264
+
265
+ If *seaborn* is installed, ``cmap`` may also be a
266
+ `seaborn color palette <https://seaborn.pydata.org/tutorial/color_palettes.html>`_.
267
+ Note: if ``cmap`` is a seaborn color palette,
253
268
``levels`` must also be specified.
254
- colors : color-like or list of color-like, optional
269
+ colors : str or array-like of color-like, optional
255
270
A single color or a list of colors. The ``levels`` argument
256
271
is required.
257
272
center : float, optional
258
273
The value at which to center the colormap. Passing this value implies
259
274
use of a diverging colormap. Setting it to ``False`` prevents use of a
260
275
diverging colormap.
261
276
robust : bool, optional
262
- If True and ``vmin`` or ``vmax`` are absent, the colormap range is
277
+ If `` True`` and ``vmin`` or ``vmax`` are absent, the colormap range is
263
278
computed with 2nd and 98th percentiles instead of the extreme values.
264
- extend : {" neither", " both", " min", " max" }, optional
279
+ extend : {' neither', ' both', ' min', ' max' }, optional
265
280
How to draw arrows extending the colorbar beyond its limits. If not
266
- provided, extend is inferred from vmin, vmax and the data limits.
267
- levels : int or list -like object , optional
268
- Split the colormap (cmap) into discrete color intervals. If an integer
281
+ provided, `` extend`` is inferred from `` vmin``, `` vmax`` and the data limits.
282
+ levels : int or array -like, optional
283
+ Split the colormap (`` cmap`` ) into discrete color intervals. If an integer
269
284
is provided, "nice" levels are chosen based on the data range: this can
270
285
imply that the final number of levels is not exactly the expected one.
271
286
Setting ``vmin`` and/or ``vmax`` with ``levels=N`` is equivalent to
272
287
setting ``levels=np.linspace(vmin, vmax, N)``.
273
288
**kwargs : optional
274
- Additional keyword arguments to matplotlib
289
+ Additional keyword arguments to wrapped Matplotlib function.
275
290
"""
276
291
277
292
# Build on the original docstring
@@ -463,9 +478,11 @@ def plotmethod(
463
478
464
479
465
480
@_dsplot
466
- def scatter (ds , x , y , ax , u , v , ** kwargs ):
481
+ def scatter (ds , x , y , ax , ** kwargs ):
467
482
"""
468
483
Scatter Dataset data variables against each other.
484
+
485
+ Wraps :py:func:`matplotlib:matplotlib.pyplot.scatter`.
469
486
"""
470
487
471
488
if "add_colorbar" in kwargs or "add_legend" in kwargs :
@@ -482,6 +499,10 @@ def scatter(ds, x, y, ax, u, v, **kwargs):
482
499
size_norm = kwargs .pop ("size_norm" , None )
483
500
size_mapping = kwargs .pop ("size_mapping" , None ) # set by facetgrid
484
501
502
+ # Remove `u` and `v` so they don't get passed to `ax.scatter`
503
+ kwargs .pop ("u" , None )
504
+ kwargs .pop ("v" , None )
505
+
485
506
# need to infer size_mapping with full dataset
486
507
data = _infer_scatter_data (ds , x , y , hue , markersize , size_norm , size_mapping )
487
508
@@ -519,7 +540,10 @@ def scatter(ds, x, y, ax, u, v, **kwargs):
519
540
520
541
@_dsplot
521
542
def quiver (ds , x , y , ax , u , v , ** kwargs ):
522
- """Quiver plot with Dataset variables."""
543
+ """Quiver plot of Dataset variables.
544
+
545
+ Wraps :py:func:`matplotlib:matplotlib.pyplot.quiver`.
546
+ """
523
547
import matplotlib as mpl
524
548
525
549
if x is None or y is None or u is None or v is None :
@@ -548,7 +572,10 @@ def quiver(ds, x, y, ax, u, v, **kwargs):
548
572
549
573
@_dsplot
550
574
def streamplot (ds , x , y , ax , u , v , ** kwargs ):
551
- """Quiver plot with Dataset variables."""
575
+ """Plot streamlines of Dataset variables.
576
+
577
+ Wraps :py:func:`matplotlib:matplotlib.pyplot.streamplot`.
578
+ """
552
579
import matplotlib as mpl
553
580
554
581
if x is None or y is None or u is None or v is None :
0 commit comments