Skip to content

Commit

Permalink
API changes in matplotlib.pyplot.scatter, added docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
spors committed Nov 11, 2020
1 parent 21553ec commit bc0eb0f
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions sfs/plot2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,38 @@ def level(p, grid, *, xnorm=None, power=False, cmap=None, vmax=3, vmin=-50,


def particles(x, *, trim=None, ax=None, xlabel='x (m)', ylabel='y (m)',
edgecolor='', marker='.', s=15, **kwargs):
"""Plot particle positions as scatter plot"""
edgecolors=None, marker='.', s=15, **kwargs):
"""Plot particle positions as scatter plot.
Parameters
----------
x : triple or pair of array_like
x, y and optionally z components of particle positions. The z
components are ignored.
If the values are complex, the imaginary parts are ignored.
Returns
-------
Scatter
See :func:`matplotlib.pyplot.scatter`.
Other Parameters
----------------
trim : array of float, optional
xmin, xmax, ymin, ymax limits for which the particles are plotted.
ax : Axes, optional
If given, the plot is created on *ax* instead of the current
axis (see :func:`matplotlib.pyplot.gca`).
xlabel, ylabel : str
Overwrite default x/y labels. Use ``xlabel=''`` and
``ylabel=''`` to remove x/y labels. The labels can be changed
afterwards with :func:`matplotlib.pyplot.xlabel` and
:func:`matplotlib.pyplot.ylabel`.
edgecolors, markr, s, **kwargs
All further parameters are forwarded to
:func:`matplotlib.pyplot.scatter`.
"""
XX, YY = [_np.real(c) for c in x[:2]]

if trim is not None:
Expand All @@ -348,7 +378,7 @@ def particles(x, *, trim=None, ax=None, xlabel='x (m)', ylabel='y (m)',
ax.set_xlabel(xlabel)
if ylabel:
ax.set_ylabel(ylabel)
return ax.scatter(XX, YY, edgecolor=edgecolor, marker=marker, s=s,
return ax.scatter(XX, YY, edgecolors=edgecolors, marker=marker, s=s,
**kwargs)


Expand Down

0 comments on commit bc0eb0f

Please sign in to comment.