dabl.plot.discrete_scatter

dabl.plot.discrete_scatter(x, y, c, unique_c=None, legend='first', clip_outliers=True, alpha='auto', s='auto', ax=None, **kwargs)[source]

Scatter plot for categories.

Creates a scatter plot for x and y grouped by c.

Parameters
xarray-like

x coordinates to scatter.

yarray-like

y coordinates to scatter.

carray-like

Grouping of samples (similar to hue in seaborn).

unique_carray-like, default=’None’

Unique values of c considered in scatter. If not provided unique elements of c are determined.

legendbool, or “first”, default=”first”

Whether to create a legend. “first” mean only the first one in a given gridspec.

clip_outliersbool, default=’True’

Whether to clip outliers in x and y. The limits are determined based on 0.01 and 0.99 quantiles of x and y ignoring nan values.

alphafloat, default=’auto’

Alpha values for scatter plots. ‘auto’ is dirty hacks.

sfloat, default=’auto’.

Marker size for scatter plots. ‘auto’ is dirty hacks.

axmatplotlib axes, default=None

Axes to plot into.

kwargs :

Passed through to plt.scatter.

Examples

>>> import matplotlib.pyplot as plt
>>> from dabl.datasets import load_ames
>>> data = load_ames()
>>> fig = plt.figure()
>>> discrete_scatter(
...    x=data["Year Built"],
...    y=data["SalePrice"],
...    c=data["Overall Qual"],
...    unique_c=[2, 4, 6, 8, 10],
...    legend=True,
...    alpha=0.3
... )