Skip to content

Commit

Permalink
Incorporate other @mathause suggestions; other fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoon committed May 13, 2021
1 parent 8216d3c commit 4328a72
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
16 changes: 10 additions & 6 deletions xarray/plot/dataset_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def _dsplot(plotfunc):
x, y : str
Variable names for the *x* and *y* grid positions.
u, v : str, optional
Variable names for *u* and *v*
(*x* and *y* velocities; quiver/streamplot plots only).
Variable names for the *u* and *v* velocities
(in *x* and *y* direction, respectively; quiver/streamplot plots only).
hue: str, optional
Variable by which to color scatter points or arrows.
hue_style: str, optional
Expand Down Expand Up @@ -474,11 +474,11 @@ def plotmethod(


@_dsplot
def scatter(ds, x, y, u, v, **kwargs):
def scatter(ds, x, y, **kwargs):
"""
Scatter Dataset data variables against each other.
Wraps :py:func:`matplotlib.pyplot.scatter`.
Wraps :py:func:`matplotlib:matplotlib.pyplot.scatter`.
"""

if "add_colorbar" in kwargs or "add_legend" in kwargs:
Expand All @@ -496,6 +496,10 @@ def scatter(ds, x, y, u, v, **kwargs):
size_norm = kwargs.pop("size_norm", None)
size_mapping = kwargs.pop("size_mapping", None) # set by facetgrid

# Remove `u` and `v` so they don't get passed to `ax.scatter`
kwargs.pop("u", None)
kwargs.pop("v", None)

# need to infer size_mapping with full dataset
data = _infer_scatter_data(ds, x, y, hue, markersize, size_norm, size_mapping)

Expand Down Expand Up @@ -535,7 +539,7 @@ def scatter(ds, x, y, u, v, **kwargs):
def quiver(ds, x, y, u, v, **kwargs):
"""Quiver plot of Dataset variables.
Wraps :py:func:`matplotlib.pyplot.quiver`.
Wraps :py:func:`matplotlib:matplotlib.pyplot.quiver`.
"""
import matplotlib as mpl

Expand Down Expand Up @@ -568,7 +572,7 @@ def quiver(ds, x, y, u, v, **kwargs):
def streamplot(ds, x, y, u, v, **kwargs):
"""Plot streamlines of Dataset variables.
Wraps :py:func:`matplotlib.pyplot.streamplot`.
Wraps :py:func:`matplotlib:matplotlib.pyplot.streamplot`.
"""
import matplotlib as mpl

Expand Down
21 changes: 11 additions & 10 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def plot(
**kwargs,
):
"""
Default plot of DataArray using :py:mod:`matplotlib.pyplot`.
Default plot of DataArray using :py:mod:`matplotlib:matplotlib.pyplot`.
Calls xarray plotting function based on the dimensions of
the :py:meth:`squeezed DataArray <xarray.DataArray.squeeze>`.
Expand Down Expand Up @@ -155,7 +155,7 @@ def plot(
are uniformly spaced. Usually a small positive number.
subplot_kws : dict, optional
Dictionary of keyword arguments for Matplotlib subplots
(see :py:meth:`matplotlib.figure.Figure.add_subplot`).
(see :py:meth:`matplotlib:matplotlib.figure.Figure.add_subplot`).
**kwargs : optional
Additional keyword arguments for Matplotlib.
Expand Down Expand Up @@ -234,7 +234,8 @@ def line(
Parameters
----------
darray : DataArray
Must be one-dimensional (1D).
Must be one-dimensional (1D), unless ``hue``, ``x``, or ``y`` is provided
(in which case it should be 2D).
figsize : tuple, optional
A tuple (width, height) of the figure in inches.
Mutually exclusive with ``size`` and ``ax``.
Expand Down Expand Up @@ -270,7 +271,7 @@ def line(
add_legend : bool, optional
Add legend with *y* axis coordinates (2D inputs only).
*args, **kwargs : optional
Additional arguments to :py:func:`matplotlib.pyplot.plot`.
Additional arguments to :py:func:`matplotlib:matplotlib.pyplot.plot`.
"""
# Handle facetgrids first
if row or col:
Expand Down Expand Up @@ -414,7 +415,7 @@ def hist(
Axes on which to plot. By default, use the current axes.
Mutually exclusive with ``size`` and ``figsize``.
**kwargs : optional
Additional keyword arguments to :py:func:`matplotlib.pyplot.hist`.
Additional keyword arguments to :py:func:`matplotlib:matplotlib.pyplot.hist`.
"""
ax = get_axis(figsize, size, aspect, ax)
Expand Down Expand Up @@ -573,12 +574,12 @@ def _plot2d(plotfunc):
subplot_kws : dict, optional
Dictionary of keyword arguments for Matplotlib subplots. Only used
for 2D and faceted plots.
(see :py:meth:`matplotlib.figure.Figure.add_subplot`).
(see :py:meth:`matplotlib:matplotlib.figure.Figure.add_subplot`).
cbar_ax : matplotlib axes object, optional
Axes in which to draw the colorbar.
cbar_kwargs : dict, optional
Dictionary of keyword arguments to pass to the colorbar
(see :meth:`matplotlib.figure.Figure.colorbar`).
(see :meth:`matplotlib:matplotlib.figure.Figure.colorbar`).
**kwargs : optional
Additional keyword arguments to wrapped Matplotlib function.
Expand Down Expand Up @@ -902,7 +903,7 @@ def imshow(x, y, z, ax, **kwargs):
dimension can be interpreted as RGB or RGBA color channels and
allows this dimension to be specified via the kwarg ``rgb=``.
Unlike :py:func:`matplotlib.pyplot.imshow`, which ignores ``vmin``/``vmax``
Unlike :py:func:`matplotlib:matplotlib.pyplot.imshow`, which ignores ``vmin``/``vmax``
for RGB(A) data,
xarray *will* use ``vmin`` and ``vmax`` for RGB(A) data
by applying a single scaling factor and offset to all bands.
Expand All @@ -913,7 +914,7 @@ def imshow(x, y, z, ax, **kwargs):
This function needs uniformly spaced coordinates to
properly label the axes. Call :py:meth:`DataArray.plot` to check.
The pixels are centered on the coordinates values. For example, if the coordinate
The pixels are centered on the coordinates. For example, if the coordinate
value is 3.2, then the pixels for those coordinates will be centered on 3.2.
"""

Expand Down Expand Up @@ -1044,7 +1045,7 @@ def surface(x, y, z, ax, **kwargs):
"""
Surface plot of 2D DataArray.
Wraps :py:func:`matplotlib:mpl_toolkits.mplot3d.axes3d.plot_surface`.
Wraps :py:meth:`matplotlib:mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface`.
"""
primitive = ax.plot_surface(x, y, z, **kwargs)
return primitive

0 comments on commit 4328a72

Please sign in to comment.