milia.plot.lets.draw#
Lets-plot primitives behind every figure (same signatures as milia.plot.mpl.draw).
Functions
|
Accent colours of the current style, for figure code. |
|
Per-entity traces over a shaded band, entities leaving it highlighted. |
|
Bar chart, dodged by |
|
Dumbbell chart: a start and end value per row, joined by a segment. |
|
Add reference lines, labels and the theme to a plot. |
|
Points of many groups, each outlined, numbered and given its own marker. |
|
Heatmap of a value over two categorical axes, optionally annotated. |
|
Histogram, optionally split by a column. |
|
Line chart: one line per series, optionally one panel per facet. |
|
Points with horizontal ranges, one row per item (e.g. ranks with intervals). |
|
Scatter plot, optionally coloured and labelled. |
|
Jittered strip of values per category. |
- milia.plot.lets.draw.finish(plot, title, xlabel, ylabel, hlines=(), vlines=())#
Add reference lines, labels and the theme to a plot.
- Parameters:
- Return type:
- Returns:
The finished
PlotSpec.
Examples
>>> import pandas as pd >>> from lets_plot import aes, geom_point, ggplot >>> plot = finish( ... ggplot(pd.DataFrame({"x": [1]}), aes(x="x", y="x")) + geom_point(), "t", "x", "y", hlines=(1,) ... ) >>> len(plot.as_dict()["layers"]) 2
- milia.plot.lets.draw.lines(frame, x, y, color=None, facet=None, points=False, group=None, hlines=(), vlines=(), title=None, xlabel=None, ylabel=None, palette=None, widths=None)#
Line chart: one line per series, optionally one panel per facet.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
frame (
DataFrame) – Long-form data.x (
str) – x column.y (
str) – y column.points (
bool) – Also mark the points.group (
str|None) – Column grouping rows into separate lines within a series.hlines (
Sequence[float]) – y values of dotted reference lines.vlines (
Sequence[float]) – x values of dotted reference lines.
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = lines(pd.DataFrame({"x": [0, 1], "y": [1.0, 2.0]}), "x", "y") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.bars(frame, x, y, fill=None, facet=None, flip=False, hlines=(), title=None, xlabel=None, ylabel=None)#
Bar chart, dodged by
fill, optionally horizontal and faceted.Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = bars(pd.DataFrame({"x": ["a", "b"], "y": [1.0, 2.0]}), "x", "y") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.heat(frame, x, y, value, text=True, title=None, xlabel=None, ylabel=None)#
Heatmap of a value over two categorical axes, optionally annotated.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = heat(pd.DataFrame({"a": ["x", "y"], "b": ["u", "u"], "v": [0.1, 0.9]}), "a", "b", "v") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.scatter(frame, x, y, color=None, label=None, hlines=(), vlines=(), title=None, xlabel=None, ylabel=None)#
Scatter plot, optionally coloured and labelled.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = scatter(pd.DataFrame({"x": [0.0, 1.0], "y": [1.0, 0.0]}), "x", "y") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.groups(frame, x, y, group, highlight=None, markers=True, numbers=True, outline=True, title=None, xlabel=None, ylabel=None)#
Points of many groups, each outlined, numbered and given its own marker.
Colour alone cannot identify many groups, so each group has a marker shape, a pale outline (the convex hull of its points) and its name at its median. Neighbouring groups take the most different colours of the palette, and one group can be drawn in the highlight colour.
Lets-plot primitive behind
milia.plot.figures.clusters.scatter().- Parameters:
frame (
DataFrame) – Data.x (
str) – x column.y (
str) – y column.group (
str) – Column naming the group of each point.highlight (
str|None) – Name of the group drawn in the highlight colour.markers (
bool) – Give each group its own marker shape.numbers (
bool) – Write the name of each group at its median.outline (
bool) – Draw the convex hull of each group in a pale tint.
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> data = pd.DataFrame({"x": [0, 1, 0, 5, 6, 5], "y": [0, 0, 1, 5, 5, 6], "g": ["1"] * 3 + ["2"] * 3}) >>> bool(groups(data, "x", "y", "g").as_dict()["layers"]) True
- milia.plot.lets.draw.strip(frame, x, y, color=None, hlines=(), title=None, xlabel=None, ylabel=None)#
Jittered strip of values per category.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = strip(pd.DataFrame({"x": ["a", "a", "b"], "y": [1.0, 2.0, 3.0]}), "x", "y") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.hist(frame, x, fill=None, vlines=(), bins=30, title=None, xlabel=None, ylabel=None)#
Histogram, optionally split by a column.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = hist(pd.DataFrame({"x": [0.1, 0.4, 0.5]}), "x", bins=3) >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.ranges(frame, y, x, low, high, title=None, xlabel=None, ylabel=None)#
Points with horizontal ranges, one row per item (e.g. ranks with intervals).
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = ranges(pd.DataFrame({"n": ["a"], "r": [1], "lo": [1], "hi": [2]}), "n", "r", "lo", "hi") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.dumbbell(frame, y, start, end, title=None, xlabel=None, ylabel=None)#
Dumbbell chart: a start and end value per row, joined by a segment.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = dumbbell(pd.DataFrame({"n": ["a"], "s": [0.9], "e": [0.2]}), "n", "s", "e") >>> bool(figure.as_dict()["layers"]) True
- milia.plot.lets.draw.band(frame, x, y, group, low, high, flagged=None, title=None, xlabel=None, ylabel=None)#
Per-entity traces over a shaded band, entities leaving it highlighted.
Lets-plot primitive behind the figures of
milia.plot.figures.- Parameters:
- Return type:
- Returns:
A lets-plot
PlotSpec.
Examples
>>> import pandas as pd >>> figure = band(pd.DataFrame({"s": [0, 1], "v": [1.0, 1.2], "g": ["a", "a"]}), "s", "v", "g", 0.9, 1.1) >>> bool(figure.as_dict()["layers"]) True