| Title: | Statistical Data Visualization, the 'seaborn' Way |
| Version: | 1.0.0 |
| Description: | An 'R' port of the 'Python' 'seaborn' library. 'reaborn' mirrors the 'seaborn' public function API (identical function names, argument names, and defaults) and renders visually indistinguishable plots using 'ggplot2'. Because every 'reaborn' plot is a 'ggplot' object, it can be extended with the full 'ggplot2' grammar of graphics. |
| License: | BSD_3_clause + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 8.0.0 |
| Depends: | R (≥ 4.1) |
| Imports: | ggplot2 (≥ 4.0.0), grDevices, grid, rlang, scales, stats |
| Suggests: | colorspace, ggbeeswarm, ggdendro, jsonlite, knitr, MASS, patchwork, ragg, rmarkdown, testthat (≥ 3.0.0), vdiffr |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| URL: | https://reaborn.org, https://github.com/shawntz/reaborn |
| BugReports: | https://github.com/shawntz/reaborn/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-06-25 19:16:10 UTC; shawnschwartz |
| Author: | Shawn Schwartz |
| Maintainer: | Shawn Schwartz <shawn.t.schwartz@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-30 20:40:02 UTC |
reaborn: Statistical Data Visualization, the Seaborn Way
Description
reaborn is an R port of the Python seaborn library. It mirrors seaborn's public function API (identical names, arguments, and defaults) and produces visually indistinguishable plots built on ggplot2. Every reaborn plot is a ggplot object, so it composes with the full ggplot2 grammar of graphics.
Author(s)
Maintainer: Shawn Schwartz shawn.t.schwartz@gmail.com (ORCID)
Authors:
Shawn Schwartz shawn.t.schwartz@gmail.com (ORCID)
See Also
Useful links:
Report bugs at https://github.com/shawntz/reaborn/issues
Add to a reaborn plot, preserving its class
Description
Ensures reaborn_plot + <ggplot component> stays a reaborn_plot so the
composed object keeps printing through reaborn and remains chainable.
Usage
## S3 method for class 'reaborn_plot'
e1 + e2
Arguments
e1 |
A reaborn plot. |
e2 |
A ggplot component (geom, scale, theme, facet, ...). |
Value
A reaborn plot.
A faceted grid of plots
Description
Lightweight port of seaborn.FacetGrid. In reaborn, faceting is usually done
by adding + ggplot2::facet_wrap()/facet_grid() to a plot, or via the
figure-level functions (relplot, displot, catplot, lmplot). This
constructor returns a base plot you can map geoms onto.
Usage
FacetGrid(
data,
row = NULL,
col = NULL,
hue = NULL,
col_wrap = NULL,
height = 3,
aspect = 1,
palette = NULL
)
Arguments
data |
A data frame. |
row, col, hue |
Faceting / hue variables. |
col_wrap |
Wrap columns at this width. |
height, aspect |
Facet sizing. |
palette |
Hue palette. |
Value
A reaborn_plot.
Get the parameters that control the general style of the plots
Description
Port of seaborn.axes_style. Returns the resolved style definition.
Usage
axes_style(style = NULL, rc = NULL)
set_style(style = NULL, rc = NULL)
Arguments
style |
One of |
rc |
Optional named list of overrides. |
Value
A named list describing the style.
Show point estimates and errors as bars
Description
Port of seaborn.barplot. Bar heights are an aggregate (default mean) with a
bootstrap CI error bar. Returns a reaborn_plot.
Usage
barplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
estimator = "mean",
errorbar = list("ci", 95),
n_boot = 1000,
seed = NULL,
units = NULL,
weights = NULL,
orient = NULL,
color = NULL,
palette = NULL,
saturation = 0.75,
fill = TRUE,
width = 0.8,
dodge = "auto",
gap = 0,
capsize = 0,
err_kws = NULL,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
estimator, errorbar, n_boot, seed |
Aggregation + error settings. |
units, weights |
Bootstrap structure / weights (units reserved). |
orient |
|
color, palette, saturation, fill |
Color controls (saturation default 0.75). |
width, gap |
Box width and gap between dodged boxes. |
dodge |
How to dodge bars by hue ( |
capsize |
Width of the error bar caps. |
err_kws |
Passed to the error bar geom. |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Draw an enhanced box plot for larger datasets
Description
Port of seaborn.boxenplot (letter-value plot). Returns a reaborn_plot.
Usage
boxenplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
orient = NULL,
color = NULL,
palette = NULL,
saturation = 0.75,
fill = TRUE,
width = 0.8,
gap = 0,
linewidth = NULL,
linecolor = NULL,
width_method = "exponential",
k_depth = "tukey",
outlier_prop = 0.007,
trust_alpha = 0.05,
showfliers = TRUE,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
orient |
|
color, palette, saturation, fill |
Color controls (saturation default 0.75). |
width, gap |
Box width and gap between dodged boxes. |
linewidth |
Box outline width. |
linecolor |
Box outline color. |
width_method |
|
k_depth |
|
outlier_prop, trust_alpha |
Tail-rule parameters. |
showfliers |
Draw outlier points. |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to ggplot2::geom_boxplot. |
Value
A reaborn_plot.
Draw a box plot
Description
Port of seaborn.boxplot. Returns a reaborn_plot.
Usage
boxplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
orient = NULL,
color = NULL,
palette = NULL,
saturation = 0.75,
fill = TRUE,
dodge = "auto",
width = 0.8,
gap = 0,
whis = 1.5,
linecolor = "auto",
linewidth = NULL,
fliersize = NULL,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
orient |
|
color, palette, saturation, fill |
Color controls (saturation default 0.75). |
dodge |
How to dodge boxes by hue ( |
width, gap |
Box width and gap between dodged boxes. |
whis |
Whisker length in IQR units (default 1.5). |
linecolor, linewidth, fliersize |
Line and outlier styling. |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to ggplot2::geom_boxplot. |
Value
A reaborn_plot.
Figure-level interface for categorical plots
Description
Port of seaborn.catplot. Dispatches to stripplot (kind = "strip"),
boxplot, barplot, pointplot, or countplot and adds row/col faceting.
Returns a faceted reaborn_plot.
Usage
catplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
row = NULL,
col = NULL,
kind = "strip",
estimator = "mean",
errorbar = list("ci", 95),
n_boot = 1000,
seed = NULL,
units = NULL,
weights = NULL,
order = NULL,
hue_order = NULL,
row_order = NULL,
col_order = NULL,
col_wrap = NULL,
height = 5,
aspect = 1,
orient = NULL,
color = NULL,
palette = NULL,
legend = "auto",
facet_kws = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
row, col, col_wrap, row_order, col_order |
Faceting controls. |
kind |
One of |
estimator, errorbar, n_boot, seed |
Aggregation settings (bar/point). |
units |
Unit grouping for bootstrap (bar/point kinds). |
weights |
Observation weights (bar/point kinds). |
order, hue_order |
Level orderings. |
height, aspect |
Facet sizing (stored as attributes). |
orient |
|
color |
Single color override. |
palette |
Palette for the hue mapping. |
legend |
Legend control. |
facet_kws |
Reserved for compatibility. |
... |
Passed to the underlying plotter. |
Value
A reaborn_plot.
Plot a hierarchically-clustered heatmap
Description
Port of seaborn.clustermap. Reorders rows/columns by hierarchical
clustering and draws dendrograms alongside the heatmap. Returns a patchwork
composition.
Usage
clustermap(
data,
method = "average",
metric = "euclidean",
z_score = NULL,
standard_scale = NULL,
row_cluster = TRUE,
col_cluster = TRUE,
cmap = NULL,
dendrogram_ratio = 0.2,
...
)
Arguments
data |
A matrix or data frame. |
method |
Linkage method (default |
metric |
Distance metric (default |
z_score |
Normalize rows ( |
standard_scale |
Scale rows ( |
row_cluster, col_cluster |
Whether to cluster rows / columns. |
cmap |
Colormap (default |
dendrogram_ratio |
Fraction of the figure used by the dendrograms. |
... |
Passed to heatmap. |
Value
A reaborn_plot (patchwork).
Return a list of colors or a continuous colormap defining a palette
Description
Port of seaborn.color_palette. Possible palette values include the name
of a seaborn palette (deep, muted, bright, pastel, dark,
colorblind), a matplotlib colormap name, "husl"/"hls", a cubehelix
shorthand ("ch:..."), "light:<color>", "dark:<color>",
"blend:<c1>,<c2>", or a sequence of colors.
Usage
color_palette(palette = NULL, n_colors = NULL, desat = NULL, as_cmap = FALSE)
hls_palette(n_colors = 6, h = 0.01, l = 0.6, s = 0.65, as_cmap = FALSE)
husl_palette(n_colors = 6, h = 0.01, s = 0.9, l = 0.65, as_cmap = FALSE)
dark_palette(
color,
n_colors = 6,
reverse = FALSE,
as_cmap = FALSE,
input = "rgb"
)
light_palette(
color,
n_colors = 6,
reverse = FALSE,
as_cmap = FALSE,
input = "rgb"
)
diverging_palette(
h_neg,
h_pos,
s = 75,
l = 50,
sep = 1,
n = 6,
center = "light",
as_cmap = FALSE
)
blend_palette(colors, n_colors = 6, as_cmap = FALSE, input = "rgb")
mpl_palette(name, n_colors = 6, as_cmap = FALSE)
cubehelix_palette(
n_colors = 6,
start = 0,
rot = 0.4,
gamma = 1,
hue = 0.8,
light = 0.85,
dark = 0.15,
reverse = FALSE,
as_cmap = FALSE
)
Arguments
palette |
|
n_colors |
Number of colors. If |
desat |
Proportion to desaturate each color by. |
as_cmap |
If |
h, l, s |
Hue, lightness, saturation anchors in |
color |
Base color for the high end of a sequential palette. |
reverse |
Reverse the direction of the blend. |
input |
Color space of the input color: |
h_neg, h_pos |
Anchor hues ( |
sep |
Size of the intermediate (center) region. |
n |
Number of colors (when not returning a cmap). |
center |
|
colors |
A sequence of colors to blend between. |
name |
Name of a matplotlib colormap. |
start, rot, gamma, hue, light, dark |
Cubehelix parameters (see seaborn). |
Value
A character vector of hex colors, or a reaborn_cmap.
Show value counts as bars
Description
Port of seaborn.countplot. Returns a reaborn_plot.
Usage
countplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
orient = NULL,
color = NULL,
palette = NULL,
saturation = 0.75,
fill = TRUE,
stat = "count",
width = 0.8,
dodge = "auto",
gap = 0,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
orient |
|
color, palette, saturation, fill |
Color controls (saturation default 0.75). |
stat |
|
width, gap |
Box width and gap between dodged boxes. |
dodge |
How to dodge bars by hue ( |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Decrease the saturation of a color
Description
Port of seaborn.desaturate.
Usage
desaturate(color, prop)
Arguments
color |
A matplotlib-compatible color. |
prop |
Proportion (in |
Value
A hex color string.
Remove spines from a plot
Description
Port of seaborn.despine. Returns a ggplot2 theme partial that removes the
requested plot borders and (for borderless styles) draws explicit axis lines
on the kept sides. Add it to a reaborn/ggplot plot: p + despine().
Usage
despine(
fig = NULL,
ax = NULL,
top = TRUE,
right = TRUE,
left = FALSE,
bottom = FALSE,
offset = NULL,
trim = FALSE
)
Arguments
fig, ax |
Ignored (kept for signature compatibility with seaborn). |
top, right, left, bottom |
Logical; whether to remove that spine. Defaults match seaborn: remove top and right, keep left and bottom. |
offset, trim |
Not supported by ggplot2; accepted but ignored in v1 with a one-time message. Present for signature compatibility. |
Value
A ggplot2 theme object to add to a plot.
Figure-level interface for distribution plots
Description
Port of seaborn.displot. Draws histplot (kind = "hist"), kdeplot
(kind = "kde"), or ecdfplot (kind = "ecdf") onto a grid of facets.
Returns a faceted reaborn_plot.
Usage
displot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
row = NULL,
col = NULL,
weights = NULL,
kind = "hist",
rug = FALSE,
rug_kws = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
color = NULL,
col_wrap = NULL,
row_order = NULL,
col_order = NULL,
legend = TRUE,
height = 5,
aspect = 1,
facet_kws = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column name/vector for the histogram variable (use |
hue |
Grouping variable for color. |
row, col, col_wrap, row_order, col_order |
Faceting controls. |
weights |
Optional observation weights. |
kind |
|
rug |
Add a marginal rug. |
rug_kws |
Arguments forwarded to the rug layer when |
palette, hue_order, hue_norm, color |
Color controls. |
legend |
Show the legend. |
height, aspect |
Facet size controls (stored as attributes). |
facet_kws |
Reserved for compatibility. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Who's a good boy?
Description
Port of seaborn.dogplot (an easter egg). Prints an affirmation.
Usage
dogplot(...)
Arguments
... |
Ignored. |
Value
Invisibly NULL.
Plot an empirical cumulative distribution function
Description
Port of seaborn.ecdfplot. Returns a reaborn_plot.
Usage
ecdfplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
weights = NULL,
stat = "proportion",
complementary = FALSE,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
legend = TRUE,
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column name/vector for the histogram variable (use |
hue |
Grouping variable for color. |
weights |
Optional observation weights. |
stat |
|
complementary |
Plot the complementary ECDF (1 - F). |
palette |
Palette for the hue mapping. |
hue_order |
Order of hue levels. |
hue_norm |
Normalization for a numeric hue. |
legend |
Show the legend. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Plot rectangular data as a color-encoded matrix
Description
Port of seaborn.heatmap. Returns a reaborn_plot.
Usage
heatmap(
data,
vmin = NULL,
vmax = NULL,
cmap = NULL,
center = NULL,
robust = FALSE,
annot = NULL,
fmt = ".2g",
annot_kws = NULL,
linewidths = 0,
linecolor = "white",
cbar = TRUE,
square = FALSE,
xticklabels = "auto",
yticklabels = "auto",
mask = NULL,
...
)
Arguments
data |
A matrix or data frame of values. |
vmin, vmax |
Color scale limits. |
cmap |
A colormap name (default |
center |
Value at which to center a diverging colormap. |
robust |
Use the 2nd/98th percentiles for the color limits. |
annot |
Annotate each cell with its value ( |
fmt |
Number format for annotations (default |
annot_kws |
Passed to the text geom. |
linewidths, linecolor |
Cell border width and color. |
cbar |
Show the color bar. |
square |
Force square cells. |
xticklabels, yticklabels |
Tick label control ( |
mask |
Logical matrix of cells to hide. |
... |
Reserved. |
Value
A reaborn_plot.
Plot a univariate or bivariate histogram
Description
Port of seaborn.histplot. Returns a reaborn_plot.
Usage
histplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
weights = NULL,
stat = "count",
bins = "auto",
binwidth = NULL,
binrange = NULL,
discrete = NULL,
cumulative = FALSE,
common_bins = TRUE,
common_norm = TRUE,
multiple = "layer",
element = "bars",
fill = TRUE,
shrink = 1,
kde = FALSE,
kde_kws = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
color = NULL,
legend = TRUE,
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column name/vector for the histogram variable (use |
hue |
Grouping variable for color. |
weights |
Optional observation weights. |
stat |
One of |
bins, binwidth, binrange, discrete |
Binning controls (see rb_hist_bins). |
cumulative |
Accumulate counts. |
common_bins, common_norm |
Share bins/normalization across hue groups. |
multiple |
|
element |
|
fill |
Whether to fill the bars. |
shrink |
Shrink bar widths by this factor. |
kde |
Overlay a KDE curve. |
kde_kws |
Arguments for the KDE (e.g. |
palette, hue_order, hue_norm, color |
Color controls. |
legend |
Show the legend. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Draw a bivariate plot with marginal distributions
Description
Port of seaborn.jointplot. Returns a patchwork composition (printable and
saveable like any reaborn plot).
Usage
jointplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
kind = "scatter",
height = 6,
ratio = 5,
space = 0.2,
color = NULL,
palette = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables. |
hue |
Grouping variable for color. |
kind |
|
height |
Figure size in inches (stored as an attribute). |
ratio |
Joint-axes-to-marginal size ratio. |
space |
Spacing between joint and marginal axes. |
color, palette |
Color controls. |
... |
Passed to the joint plotting function. |
Value
A reaborn_plot (patchwork).
Plot a univariate or bivariate kernel density estimate
Description
Port of seaborn.kdeplot. The KDE matches scipy.stats.gaussian_kde exactly.
Returns a reaborn_plot.
Usage
kdeplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
weights = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
color = NULL,
fill = NULL,
multiple = "layer",
common_norm = TRUE,
common_grid = FALSE,
cumulative = FALSE,
bw_method = "scott",
bw_adjust = 1,
log_scale = NULL,
levels = 10,
thresh = 0.05,
gridsize = 200,
cut = 3,
clip = NULL,
legend = TRUE,
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column name/vector for the histogram variable (use |
hue |
Grouping variable for color. |
weights |
Optional observation weights. |
palette, hue_order, hue_norm, color |
Color controls. |
fill |
Fill under the density curve (default |
multiple |
|
common_norm, common_grid |
Share normalization / evaluation grid across hue groups. |
cumulative |
Plot the cumulative distribution. |
bw_method, bw_adjust |
Bandwidth controls (scipy-compatible). |
log_scale |
Reserved for compatibility. |
levels, thresh |
Bivariate contour levels and density threshold. |
gridsize, cut, clip |
KDE grid controls. |
legend |
Show the legend. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Draw a line plot with aggregation and error bands
Description
Port of seaborn.lineplot. When the data has repeated observations per x
value, they are aggregated (default: mean) and an error band (default: 95%
bootstrap CI) is drawn. Returns a reaborn_plot.
Usage
lineplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
size = NULL,
style = NULL,
units = NULL,
weights = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
sizes = NULL,
size_order = NULL,
size_norm = NULL,
dashes = TRUE,
markers = NULL,
style_order = NULL,
estimator = "mean",
errorbar = list("ci", 95),
n_boot = 1000,
seed = NULL,
orient = "x",
sort = TRUE,
err_style = "band",
err_kws = NULL,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column names (strings) or vectors giving the axes. |
hue, size, style |
Column names/vectors for color, size, and marker-style semantics. |
units, weights |
Column names/vectors for the unit grouping and weights. |
palette, hue_order, hue_norm |
Control the color mapping. |
sizes, size_order, size_norm |
Control the size mapping. |
dashes, markers |
Style mapping controls. |
style_order |
Order of style levels. |
estimator |
Aggregation function name or callable (default |
errorbar |
Error representation: a method name or |
n_boot, seed |
Bootstrap settings for |
orient, sort, err_style, err_kws |
See seaborn. |
legend |
|
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to ggplot2::geom_line. |
Value
A reaborn_plot.
Figure-level interface for regression plots
Description
Port of seaborn.lmplot. Draws regplot across a grid of facets and/or hue
groups. Returns a reaborn_plot.
Usage
lmplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
col = NULL,
row = NULL,
palette = NULL,
col_wrap = NULL,
height = 5,
aspect = 1,
order = 1,
logistic = FALSE,
lowess = FALSE,
robust = FALSE,
logx = FALSE,
ci = 95,
n_boot = 1000,
seed = NULL,
scatter = TRUE,
fit_reg = TRUE,
hue_order = NULL,
row_order = NULL,
col_order = NULL,
legend = TRUE,
facet_kws = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables. |
hue, col, row |
Semantic / faceting variables. |
palette |
Hue palette. |
col_wrap, row_order, col_order, hue_order |
Ordering / wrapping. |
height, aspect |
Facet sizing. |
order |
Polynomial order for the fit (default 1, linear). |
logistic, lowess, robust, logx |
Alternative fits. |
ci |
Confidence-band width (default 95; |
n_boot, seed |
Bootstrap settings. |
scatter, fit_reg |
Whether to draw the scatter / the fit. |
legend, facet_kws |
Legend / facet options. |
... |
Reserved. |
Value
A reaborn_plot.
Load an example dataset from the seaborn-data repository
Description
Port of seaborn.load_dataset. Bundled datasets (penguins, tips, iris,
flights) load offline; others download from the seaborn-data repo and cache.
Usage
load_dataset(name, cache = TRUE, data_home = NULL, ...)
get_dataset_names()
Arguments
name |
Name of the dataset (the stem of a |
cache |
Whether to use the local cache (and bundled data). |
data_home |
Optional cache directory. |
... |
Reserved for compatibility. |
Value
A data.frame, with categorical columns coerced to ordered factors matching seaborn.
For get_dataset_names, a character vector of available dataset names.
Reposition a plot's legend
Description
Port of seaborn.move_legend. Returns a theme partial controlling legend
position. Add it to a plot: p + move_legend("upper right").
Usage
move_legend(obj = NULL, loc = "best", ...)
Arguments
obj |
Ignored (signature compatibility). |
loc |
A seaborn/matplotlib location string (e.g. |
... |
Additional theme arguments (e.g. |
Value
A ggplot2 theme object to add to a plot.
Plot pairwise relationships in a dataset
Description
Port of seaborn.pairplot. Returns a patchwork matrix of scatter plots with
univariate distributions on the diagonal.
Usage
pairplot(
data,
vars = NULL,
hue = NULL,
kind = "scatter",
diag_kind = "auto",
palette = NULL,
height = 2.5,
aspect = 1,
corner = FALSE,
...
)
Arguments
data |
A data frame. |
vars |
Columns to include (default all numeric). |
hue |
Grouping variable for color. |
kind |
Off-diagonal kind: |
diag_kind |
Diagonal kind: |
palette, height, aspect, corner |
Layout controls. |
... |
Reserved. |
Value
A reaborn_plot (patchwork).
Plot the values in a color palette as a horizontal array
Description
Port of seaborn.palplot. Returns a reaborn_plot.
Usage
palplot(pal, size = 1)
Arguments
pal |
A sequence of colors (e.g. from color_palette). |
size |
Scaling factor for the swatch size. |
Value
A reaborn_plot.
Get the parameters that control the scaling of plot elements
Description
Port of seaborn.plotting_context. Returns a named list of resolved sizes.
Usage
plotting_context(context = NULL, font_scale = 1, rc = NULL)
set_context(context = NULL, font_scale = 1, rc = NULL)
Arguments
context |
One of |
font_scale |
Separate scaling factor applied to the font sizes only. |
rc |
Optional named list of overrides. |
Value
A named list of context parameters.
Show point estimates and errors with markers
Description
Port of seaborn.pointplot. Returns a reaborn_plot.
Usage
pointplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
estimator = "mean",
errorbar = list("ci", 95),
n_boot = 1000,
seed = NULL,
units = NULL,
weights = NULL,
color = NULL,
palette = NULL,
markers = "o",
linestyles = "-",
dodge = FALSE,
orient = NULL,
capsize = 0,
legend = "auto",
err_kws = NULL,
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
estimator, errorbar, n_boot, seed |
Aggregation + error settings. |
units, weights |
Bootstrap structure / weights (units reserved). |
color |
Single color override. |
palette |
Palette for the hue mapping. |
markers, linestyles |
Marker and line styling. |
dodge |
Dodge points by hue. |
orient |
|
capsize |
Width of the error bar caps. |
legend |
Legend control. |
err_kws |
Passed to the error bar geom. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Python literal compatibility values
Description
True, False, and None are provided so that seaborn Python code pasted
into R (e.g. histplot(data = df, x = "a", kde = True)) runs unchanged.
They are exactly TRUE, FALSE, and NULL.
Usage
True
False
None
Format
True and False are length-one logicals; None is NULL.
Value
These objects are exported constants, not functions. Referencing one yields
its stored value: True is the length-one logical vector TRUE, False is
the length-one logical vector FALSE, and None is NULL. They exist only
so that seaborn code containing Python's True, False, and None literals
evaluates in R unchanged.
Assign plot variables from data + role references
Description
Assign plot variables from data + role references
Usage
rb_assign_variables(data = NULL, ...)
Arguments
data |
A data frame, or |
... |
Named role assignments ( |
Value
A list with data (tidy frame, columns named by role), names
(role -> original variable name), and types (role -> variable type).
Univariate Gaussian KDE matching scipy.stats.gaussian_kde
Description
Univariate Gaussian KDE matching scipy.stats.gaussian_kde
Usage
rb_gaussian_kde(
x,
bw_method = "scott",
bw_adjust = 1,
gridsize = 200,
cut = 3,
clip = NULL,
weights = NULL,
cumulative = FALSE
)
Arguments
x |
Numeric data. |
bw_method |
|
bw_adjust |
Multiplicative bandwidth adjustment (seaborn |
gridsize |
Number of evaluation points (seaborn default 200). |
cut |
Extend the grid |
clip |
Length-2 numeric clip for the grid, or |
weights |
Optional observation weights. |
cumulative |
Return the cumulative distribution instead of the density. |
Value
A list with x (grid) and y (density) vectors.
Histogram bin edges matching numpy.histogram_bin_edges
Description
Histogram bin edges matching numpy.histogram_bin_edges
Usage
rb_hist_bins(
x,
bins = "auto",
binrange = NULL,
binwidth = NULL,
discrete = FALSE
)
Arguments
x |
Numeric data. |
bins |
A rule name ( |
binrange |
Optional |
binwidth |
Optional explicit bin width (overrides |
discrete |
If |
Value
A numeric vector of bin edges.
A continuous reaborn colormap
Description
Constructed internally by palette functions when as_cmap = TRUE. It wraps a
256-row RGB lookup table and is a function mapping values in [0, 1] to hex
colors via matplotlib's floor-index quantization. The hex LUT is stored in
attr(., "colors").
Usage
rb_make_cmap(lut256, name = "reaborn")
Matplotlib-style axis breaks
Description
Approximates matplotlib's MaxNLocator / AutoLocator (the default axis tick
locator), which places ticks at "nice" round numbers using the step sequence
1, 2, 2.5, 5, 10. ggplot2's default (scales::extended_breaks) targets fewer
ticks and lands on different values, so reaborn plots use this to match
seaborn's gridline density and tick positions.
Usage
rb_mpl_breaks(n = 9)
Arguments
n |
Target maximum number of intervals (matplotlib's default is ~9). |
Value
A function of limits returning a numeric vector of break positions,
suitable for the breaks argument of a ggplot2 continuous scale.
Wrap a ggplot as a reaborn plot
Description
Wrap a ggplot as a reaborn plot
Usage
reaborn_plot(plot, call = NULL)
Arguments
plot |
A ggplot object. |
call |
Optional originating call, recorded as an attribute. |
Value
The plot with class reaborn_plot prepended.
Plot data and a linear regression model fit
Description
Port of seaborn.regplot. The confidence band is a bootstrap interval, like
seaborn. Returns a reaborn_plot.
Usage
regplot(
data = NULL,
x = NULL,
y = NULL,
order = 1,
logistic = FALSE,
lowess = FALSE,
robust = FALSE,
logx = FALSE,
ci = 95,
n_boot = 1000,
seed = NULL,
scatter = TRUE,
fit_reg = TRUE,
color = NULL,
marker = "o",
scatter_kws = NULL,
line_kws = NULL,
truncate = TRUE,
x_jitter = NULL,
y_jitter = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables. |
order |
Polynomial order for the fit (default 1, linear). |
logistic, lowess, robust, logx |
Alternative fits. |
ci |
Confidence-band width (default 95; |
n_boot, seed |
Bootstrap settings. |
scatter, fit_reg |
Whether to draw the scatter / the fit. |
color |
Color for points and line (default the first palette color). |
marker |
Marker (accepted for compatibility). |
scatter_kws, line_kws |
Lists of extra args for the point / line layers. |
truncate |
Limit the regression line to the data range. |
x_jitter |
Uniform jitter added to x for display only. |
y_jitter |
Uniform jitter added to y for display only. |
... |
Reserved. |
Value
A reaborn_plot.
Figure-level interface for relational plots
Description
Port of seaborn.relplot. Draws scatterplot (kind = "scatter") or
lineplot (kind = "line") onto a grid of facets defined by row/col.
Returns a reaborn_plot (a faceted ggplot) with the legend outside, like a
seaborn FacetGrid.
Usage
relplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
size = NULL,
style = NULL,
units = NULL,
weights = NULL,
row = NULL,
col = NULL,
col_wrap = NULL,
row_order = NULL,
col_order = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
sizes = NULL,
size_order = NULL,
size_norm = NULL,
markers = NULL,
dashes = NULL,
style_order = NULL,
legend = "auto",
kind = "scatter",
height = 5,
aspect = 1,
facet_kws = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Column names (strings) or vectors giving the axes. |
hue, size, style |
Column names/vectors for color, size, and marker-style semantics. |
units, weights |
Column names/vectors for the unit grouping and weights. |
row, col |
Column names to facet by. |
col_wrap |
Wrap the column facets at this width. |
row_order, col_order |
Facet orderings. |
palette, hue_order, hue_norm |
Control the color mapping. |
sizes, size_order, size_norm |
Control the size mapping. |
dashes, markers |
Style mapping controls. |
style_order |
Order of style levels. |
legend |
|
kind |
|
height, aspect |
Facet height (inches) and aspect ratio (stored as attributes used as defaults when saving). |
facet_kws |
Reserved for compatibility. |
... |
Passed to ggplot2::geom_line. |
Value
A reaborn_plot.
Restore matplotlib/ggplot2 defaults
Description
Port of seaborn.reset_defaults / seaborn.reset_orig.
Usage
reset_defaults()
reset_orig()
Value
Invisibly NULL.
Plot the residuals of a linear regression
Description
Port of seaborn.residplot. Returns a reaborn_plot.
Usage
residplot(
data = NULL,
x = NULL,
y = NULL,
lowess = FALSE,
order = 1,
robust = FALSE,
color = NULL,
scatter_kws = NULL,
line_kws = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables. |
lowess |
Add a lowess smooth of the residuals. |
order |
Polynomial order for the fit (default 1, linear). |
robust |
Fit a robust regression when computing residuals. |
color |
Color for points and line (default the first palette color). |
scatter_kws, line_kws |
Lists of extra args for the point / line layers. |
... |
Reserved. |
Value
A reaborn_plot.
Plot marginal rug ticks
Description
Port of seaborn.rugplot. Draws small ticks at each observation along the
relevant axis. Returns a reaborn_plot (typically added to another plot, but
usable standalone).
Usage
rugplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
height = 0.025,
expand_margins = TRUE,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
legend = TRUE,
...
)
Arguments
data |
A data frame. |
x, y |
Column name/vector for the histogram variable (use |
hue |
Grouping variable for color. |
height |
Tick height as a fraction of the axis (default |
expand_margins |
Reserved for compatibility. |
palette |
Palette for the hue mapping. |
hue_order |
Order of hue levels. |
hue_norm |
Normalization for a numeric hue. |
legend |
Show the legend. |
... |
Passed to the bar geom. |
Value
A reaborn_plot.
Increase the saturation of a color to its maximum
Description
Port of seaborn.saturate.
Usage
saturate(color)
Arguments
color |
A matplotlib-compatible color. |
Value
A hex color string.
Draw a scatter plot with semantic mappings
Description
Port of seaborn.scatterplot. Returns a reaborn_plot (a ggplot), so it can
be extended with any ggplot2 component.
Usage
scatterplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
size = NULL,
style = NULL,
palette = NULL,
hue_order = NULL,
hue_norm = NULL,
sizes = NULL,
size_order = NULL,
size_norm = NULL,
markers = TRUE,
style_order = NULL,
legend = "auto",
...
)
Arguments
data |
A data frame. |
x, y |
Column names (strings) or vectors giving the axes. |
hue, size, style |
Column names/vectors for color, size, and marker-style semantics. |
palette, hue_order, hue_norm |
Control the color mapping. |
sizes, size_order, size_norm |
Control the size mapping. |
markers, style_order |
Control the style (marker) mapping. |
legend |
|
... |
Passed to ggplot2::geom_point. |
Value
A reaborn_plot.
Change how single-letter color codes are interpreted
Description
Port of seaborn.set_color_codes. Returns (invisibly) the mapping from the
single-letter codes b g r m y c k to the colors of the given seaborn
palette, so reaborn helpers can resolve them like seaborn does.
Usage
set_color_codes(palette = "deep")
Arguments
palette |
One of |
Value
Invisibly, the named character vector of code -> hex mappings.
Independently set the hue, lightness, and/or saturation of a color
Description
Port of seaborn.set_hls_values.
Usage
set_hls_values(color, h = NULL, l = NULL, s = NULL)
Arguments
color |
A matplotlib-compatible color. |
h, l, s |
New hue, lightness, saturation in |
Value
A hex color string.
Set the matplotlib color cycle / ggplot default discrete palette
Description
Port of seaborn.set_palette.
Usage
set_palette(palette, n_colors = NULL, desat = NULL, color_codes = FALSE)
Arguments
palette |
A palette name or sequence (see color_palette). |
n_colors, desat, color_codes |
See seaborn. |
Value
Invisibly NULL.
Set multiple theme parameters in one step
Description
Port of seaborn.set_theme (and its alias set). Sets the global look used
by subsequent reaborn (and ggplot2) plots.
Usage
set_theme(
context = "notebook",
style = "darkgrid",
palette = "deep",
font = "sans",
font_scale = 1,
color_codes = TRUE,
rc = NULL
)
set(...)
Arguments
context, style, palette, font, font_scale, color_codes, rc |
See seaborn. |
... |
Passed to set_theme. |
Value
Invisibly, the applied ggplot2::theme.
seaborn-style sns. function aliases
Description
For copy-paste compatibility with Python, reaborn provides a sns.-prefixed
alias for every public plotting, palette, and theming function (R allows dots
in identifiers). So pasted seaborn code such as
sns.scatterplot(data = df, x = "a", y = "b", hue = "g") runs verbatim.
Each alias is identical to its unprefixed counterpart; see that function for
arguments and details.
Value
Each sns.-prefixed object is the exact same function as its unprefixed
counterpart (sns.scatterplot <- scatterplot, and so on), so calling an
alias returns precisely what the counterpart returns. By category: the
plotting functions (e.g. sns.scatterplot(), sns.histplot(),
sns.heatmap(), sns.pairplot(), sns.FacetGrid(), sns.palplot()) return
a reaborn_plot object (a ggplot2/patchwork object that draws when printed),
except the easter-egg sns.dogplot(), which prints an affirmation and
returns NULL invisibly;
the palette constructors (e.g. sns.color_palette(), sns.husl_palette(),
sns.cubehelix_palette()) return a character vector of hex colors, or a
reaborn_cmap; the color helpers sns.desaturate(), sns.saturate(), and
sns.set_hls_values() return a hex color string; sns.axes_style() and
sns.plotting_context() return a named list of style/context parameters;
sns.despine() and sns.move_legend() return a ggplot2 theme object to add
to a plot; sns.load_dataset() returns a data frame and
sns.get_dataset_names() a character vector; and the theming setters
(sns.set_theme(), sns.set(), sns.set_style(), sns.set_context(),
sns.set_palette(), sns.set_color_codes(), sns.reset_defaults(),
sns.reset_orig()) are called for their side effect of changing global plot
defaults and return their value invisibly. See each unprefixed function's own
help page for the precise structure and meaning of its return value.
Examples
pen <- load_dataset("penguins")
p <- sns.scatterplot(data = pen, x = "bill_length_mm", y = "bill_depth_mm",
hue = "species")
Draw a categorical scatter with jitter
Description
Port of seaborn.stripplot. Returns a reaborn_plot.
Usage
stripplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
jitter = TRUE,
dodge = FALSE,
orient = NULL,
color = NULL,
palette = NULL,
size = 5,
edgecolor = "gray",
linewidth = 0,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
jitter |
|
dodge |
Separate hue levels along the categorical axis. |
orient |
|
color |
Single color override. |
palette |
Palette for the hue mapping. |
size |
Marker size (seaborn default 5). |
edgecolor, linewidth |
Marker edge styling. |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to the point geom. |
Value
A reaborn_plot.
Draw a categorical scatter with non-overlapping points
Description
Port of seaborn.swarmplot, using a beeswarm layout. Returns a reaborn_plot.
Usage
swarmplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
dodge = FALSE,
orient = NULL,
color = NULL,
palette = NULL,
size = 5,
edgecolor = NULL,
linewidth = 0,
legend = "auto",
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
dodge |
Separate hue levels along the categorical axis. |
orient |
|
color |
Single color override. |
palette |
Palette for the hue mapping. |
size |
Marker size (seaborn default 5). |
edgecolor, linewidth |
Marker edge styling. |
legend |
Legend control. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to ggbeeswarm::geom_beeswarm. |
Value
A reaborn_plot.
Build a ggplot2 theme replicating a seaborn style + context
Description
Build a ggplot2 theme replicating a seaborn style + context
Usage
theme_seaborn(
style = "darkgrid",
context = "notebook",
font_scale = 1,
font = "sans"
)
Arguments
style |
A seaborn style name (see axes_style). |
context |
A seaborn context name (see plotting_context). |
font_scale |
Font scaling factor. |
font |
Base font family. |
Value
A complete ggplot2::theme object.
Draw a violin plot
Description
Port of seaborn.violinplot. The kernel density matches
scipy.stats.gaussian_kde. Returns a reaborn_plot.
Usage
violinplot(
data = NULL,
x = NULL,
y = NULL,
hue = NULL,
order = NULL,
hue_order = NULL,
orient = NULL,
color = NULL,
palette = NULL,
saturation = 0.75,
fill = TRUE,
inner = "box",
split = FALSE,
width = 0.8,
dodge = "auto",
gap = 0,
linewidth = NULL,
linecolor = "auto",
cut = 2,
gridsize = 100,
bw_method = "scott",
bw_adjust = 1,
density_norm = "area",
common_norm = FALSE,
legend = "auto",
inner_kws = NULL,
.facet_vars = NULL,
...
)
Arguments
data |
A data frame. |
x, y |
Variables; the categorical one defines the groups. |
hue |
Grouping variable for color (dodged). |
order, hue_order |
Level orderings. |
orient |
|
color, palette, saturation, fill |
Color controls (saturation default 0.75). |
inner |
|
split |
Draw split violins for two hue levels. |
width, gap |
Box width and gap between dodged boxes. |
dodge |
How to dodge violins by hue ( |
linewidth |
Outline width. |
linecolor |
Outline color ( |
cut, gridsize, bw_method, bw_adjust |
KDE controls. |
density_norm |
|
common_norm |
Normalize densities across all groups together. |
legend |
Legend control. |
inner_kws |
Passed to the inner annotation geoms. |
.facet_vars |
Internal; facet columns forwarded by the figure-level dispatchers (catplot/displot/relplot). Not intended for direct use. |
... |
Passed to ggplot2::geom_boxplot. |
Value
A reaborn_plot.