biplot-geoms | R Documentation |
These geometric element layers (geoms) pair
conventional ggplot2 geoms with stat_rows()
or
stat_cols()
in order to render elements for one or the other
matrix factor of a tbl_ord. They understand the same aesthetics
as their corresponding conventional geoms.
geom_rows_point(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_point(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_path(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
lineend = "butt",
linejoin = "round",
linemitre = 10,
arrow = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_path(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
lineend = "butt",
linejoin = "round",
linemitre = 10,
arrow = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_polygon(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
rule = "evenodd",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_polygon(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
rule = "evenodd",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_contour(
mapping = NULL,
data = NULL,
stat = "contour",
position = "identity",
...,
bins = NULL,
binwidth = NULL,
breaks = NULL,
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_contour(
mapping = NULL,
data = NULL,
stat = "contour",
position = "identity",
...,
bins = NULL,
binwidth = NULL,
breaks = NULL,
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_density_2d(
mapping = NULL,
data = NULL,
stat = "density_2d",
position = "identity",
...,
contour_var = "density",
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_density_2d(
mapping = NULL,
data = NULL,
stat = "density_2d",
position = "identity",
...,
contour_var = "density",
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_density_2d_filled(
mapping = NULL,
data = NULL,
stat = "density_2d_filled",
position = "identity",
...,
contour_var = "density",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_density_2d_filled(
mapping = NULL,
data = NULL,
stat = "density_2d_filled",
position = "identity",
...,
contour_var = "density",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_text(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
check_overlap = FALSE,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_text(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
check_overlap = FALSE,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_label(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
label.padding = unit(0.25, "lines"),
label.r = unit(0.15, "lines"),
label.size = 0.25,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_label(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
label.padding = unit(0.25, "lines"),
label.r = unit(0.15, "lines"),
label.size = 0.25,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_text_repel(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
parse = FALSE,
...,
box.padding = 0.25,
point.padding = 1e-06,
min.segment.length = 0.5,
arrow = NULL,
force = 1,
force_pull = 1,
max.time = 0.5,
max.iter = 10000,
max.overlaps = getOption("ggrepel.max.overlaps", default = 10),
nudge_x = 0,
nudge_y = 0,
xlim = c(NA, NA),
ylim = c(NA, NA),
na.rm = FALSE,
show.legend = NA,
direction = c("both", "y", "x"),
seed = NA,
verbose = FALSE,
inherit.aes = TRUE
)
geom_cols_text_repel(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
parse = FALSE,
...,
box.padding = 0.25,
point.padding = 1e-06,
min.segment.length = 0.5,
arrow = NULL,
force = 1,
force_pull = 1,
max.time = 0.5,
max.iter = 10000,
max.overlaps = getOption("ggrepel.max.overlaps", default = 10),
nudge_x = 0,
nudge_y = 0,
xlim = c(NA, NA),
ylim = c(NA, NA),
na.rm = FALSE,
show.legend = NA,
direction = c("both", "y", "x"),
seed = NA,
verbose = FALSE,
inherit.aes = TRUE
)
geom_rows_label_repel(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
parse = FALSE,
...,
box.padding = 0.25,
label.padding = 0.25,
point.padding = 1e-06,
label.r = 0.15,
label.size = 0.25,
min.segment.length = 0.5,
arrow = NULL,
force = 1,
force_pull = 1,
max.time = 0.5,
max.iter = 10000,
max.overlaps = getOption("ggrepel.max.overlaps", default = 10),
nudge_x = 0,
nudge_y = 0,
xlim = c(NA, NA),
ylim = c(NA, NA),
na.rm = FALSE,
show.legend = NA,
direction = c("both", "y", "x"),
seed = NA,
verbose = FALSE,
inherit.aes = TRUE
)
geom_cols_label_repel(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
parse = FALSE,
...,
box.padding = 0.25,
label.padding = 0.25,
point.padding = 1e-06,
label.r = 0.15,
label.size = 0.25,
min.segment.length = 0.5,
arrow = NULL,
force = 1,
force_pull = 1,
max.time = 0.5,
max.iter = 10000,
max.overlaps = getOption("ggrepel.max.overlaps", default = 10),
nudge_x = 0,
nudge_y = 0,
xlim = c(NA, NA),
ylim = c(NA, NA),
na.rm = FALSE,
show.legend = NA,
direction = c("both", "y", "x"),
seed = NA,
verbose = FALSE,
inherit.aes = TRUE
)
geom_rows_axis(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
axis_labels = TRUE,
axis_ticks = TRUE,
axis_text = TRUE,
by = NULL,
num = NULL,
tick_length = 0.025,
text_dodge = 0.03,
label_dodge = 0.03,
...,
axis.colour = NULL,
axis.color = NULL,
axis.alpha = NULL,
label.angle = 0,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
tick.linewidth = 0.25,
tick.colour = NULL,
tick.color = NULL,
tick.alpha = NULL,
text.size = 2.6,
text.angle = 0,
text.hjust = 0.5,
text.vjust = 0.5,
text.family = NULL,
text.fontface = NULL,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_axis(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
axis_labels = TRUE,
axis_ticks = TRUE,
axis_text = TRUE,
by = NULL,
num = NULL,
tick_length = 0.025,
text_dodge = 0.03,
label_dodge = 0.03,
...,
axis.colour = NULL,
axis.color = NULL,
axis.alpha = NULL,
label.angle = 0,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
tick.linewidth = 0.25,
tick.colour = NULL,
tick.color = NULL,
tick.alpha = NULL,
text.size = 2.6,
text.angle = 0,
text.hjust = 0.5,
text.vjust = 0.5,
text.family = NULL,
text.fontface = NULL,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_bagplot(
mapping = NULL,
data = NULL,
stat = "bagplot",
position = "identity",
...,
bag.linewidth = sync(),
bag.linetype = sync(),
bag.colour = "black",
bag.color = NULL,
bag.fill = sync(),
bag.alpha = NA,
median.shape = 21L,
median.stroke = sync(),
median.size = 5,
median.colour = sync(),
median.color = NULL,
median.fill = "white",
median.alpha = NA,
fence.linewidth = 0.25,
fence.linetype = 0L,
fence.colour = sync(),
fence.color = NULL,
fence.fill = sync(),
fence.alpha = 0.25,
outlier.shape = sync(),
outlier.stroke = sync(),
outlier.size = sync(),
outlier.colour = sync(),
outlier.color = NULL,
outlier.fill = NA,
outlier.alpha = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_bagplot(
mapping = NULL,
data = NULL,
stat = "bagplot",
position = "identity",
...,
bag.linewidth = sync(),
bag.linetype = sync(),
bag.colour = "black",
bag.color = NULL,
bag.fill = sync(),
bag.alpha = NA,
median.shape = 21L,
median.stroke = sync(),
median.size = 5,
median.colour = sync(),
median.color = NULL,
median.fill = "white",
median.alpha = NA,
fence.linewidth = 0.25,
fence.linetype = 0L,
fence.colour = sync(),
fence.color = NULL,
fence.fill = sync(),
fence.alpha = 0.25,
outlier.shape = sync(),
outlier.stroke = sync(),
outlier.size = sync(),
outlier.colour = sync(),
outlier.color = NULL,
outlier.fill = NA,
outlier.alpha = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_interpolation(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
new_data = NULL,
type = c("centroid", "sequence"),
arrow = default_arrow,
...,
point.fill = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_interpolation(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
new_data = NULL,
type = c("centroid", "sequence"),
arrow = default_arrow,
...,
point.fill = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_lineranges(
mapping = NULL,
data = NULL,
stat = "center",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_lineranges(
mapping = NULL,
data = NULL,
stat = "center",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_pointranges(
mapping = NULL,
data = NULL,
stat = "center",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_pointranges(
mapping = NULL,
data = NULL,
stat = "center",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_isoline(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
isoline_text = TRUE,
by = NULL,
num = NULL,
text_dodge = 0.03,
...,
text.size = 3,
text.angle = 0,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_isoline(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
isoline_text = TRUE,
by = NULL,
num = NULL,
text_dodge = 0.03,
...,
text.size = 3,
text.angle = 0,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_rule(
mapping = NULL,
data = NULL,
stat = "rule",
position = "identity",
axis_labels = TRUE,
axis_ticks = TRUE,
axis_text = TRUE,
by = NULL,
num = NULL,
snap_rule = TRUE,
tick_length = 0.025,
text_dodge = 0.03,
label_dodge = 0.03,
...,
axis.colour = NULL,
axis.color = NULL,
axis.alpha = NULL,
label.angle = 0,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
tick.linewidth = 0.25,
tick.colour = NULL,
tick.color = NULL,
tick.alpha = NULL,
text.size = 2.6,
text.angle = 0,
text.hjust = 0.5,
text.vjust = 0.5,
text.family = NULL,
text.fontface = NULL,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_rule(
mapping = NULL,
data = NULL,
stat = "rule",
position = "identity",
axis_labels = TRUE,
axis_ticks = TRUE,
axis_text = TRUE,
by = NULL,
num = NULL,
snap_rule = TRUE,
tick_length = 0.025,
text_dodge = 0.03,
label_dodge = 0.03,
...,
axis.colour = NULL,
axis.color = NULL,
axis.alpha = NULL,
label.angle = 0,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
tick.linewidth = 0.25,
tick.colour = NULL,
tick.color = NULL,
tick.alpha = NULL,
text.size = 2.6,
text.angle = 0,
text.hjust = 0.5,
text.vjust = 0.5,
text.family = NULL,
text.fontface = NULL,
text.colour = NULL,
text.color = NULL,
text.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_text_radiate(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_text_radiate(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_rows_vector(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
arrow = default_arrow,
lineend = "round",
linejoin = "mitre",
vector_labels = TRUE,
...,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_cols_vector(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
arrow = default_arrow,
lineend = "round",
linejoin = "mitre",
vector_labels = TRUE,
...,
label.colour = NULL,
label.color = NULL,
label.alpha = NULL,
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Additional arguments passed to |
na.rm |
Passed to |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
arrow |
Arrow specification, as created by |
rule |
Either |
bins |
Number of contour bins. Overridden by |
binwidth |
The width of the contour bins. Overridden by |
breaks |
One of:
Overrides |
contour_var |
Character string identifying the variable to contour
by. Can be one of |
parse |
If |
nudge_x , nudge_y |
Horizontal and vertical adjustment to nudge labels by.
Useful for offsetting text from points, particularly on discrete scales.
Cannot be jointly specified with |
check_overlap |
If |
size.unit |
How the |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
label.size |
Size of label border, in mm. |
box.padding |
Amount of padding around bounding box, as unit or number.
Defaults to 0.25. (Default unit is lines, but other units can be specified
by passing |
point.padding |
Amount of padding around labeled point, as unit or
number. Defaults to 0. (Default unit is lines, but other units can be
specified by passing |
min.segment.length |
Skip drawing segments shorter than this, as unit or
number. Defaults to 0.5. (Default unit is lines, but other units can be
specified by passing |
force |
Force of repulsion between overlapping text labels. Defaults to 1. |
force_pull |
Force of attraction between a text label and its corresponding data point. Defaults to 1. |
max.time |
Maximum number of seconds to try to resolve overlaps. Defaults to 0.5. |
max.iter |
Maximum number of iterations to try to resolve overlaps. Defaults to 10000. |
max.overlaps |
Exclude text labels when they overlap too many other things. For each text label, we count how many other text labels or other data points it overlaps, and exclude the text label if it has too many overlaps. Defaults to 10. |
xlim , ylim |
Limits for the x and y axes. Text labels will be constrained to these limits. By default, text labels are constrained to the entire plot area. |
direction |
direction of stairs: 'vh' for vertical then horizontal, 'hv' for horizontal then vertical, or 'mid' for step half-way between adjacent x-values. |
seed |
Random seed passed to |
verbose |
If |
axis_labels , axis_ticks , axis_text |
Logical; whether to include labels, tick marks, and text value marks along the axes. |
by , num |
Intervals between elements or number of elements; specify only one. |
tick_length |
Numeric; the length of the tick marks, as a proportion of the minimum of the plot width and height. |
text_dodge |
Numeric; the orthogonal distance of tick mark text from the axis, as a proportion of the minimum of the plot width and height. |
label_dodge |
Numeric; the orthogonal distance of the axis label from the axis, as a proportion of the minimum of the plot width and height. |
axis.colour , axis.color , axis.alpha |
Default aesthetics for axes. Set to NULL to inherit from the data's aesthetics. |
label.angle , label.colour , label.color , label.alpha |
Default aesthetics for labels. Set to NULL to inherit from the data's aesthetics. |
tick.linewidth , tick.colour , tick.color , tick.alpha |
Default aesthetics for tick marks. Set to NULL to inherit from the data's aesthetics. |
text.size , text.angle , text.hjust , text.vjust , text.family , text.fontface , text.colour , text.color , text.alpha |
Default aesthetics for tick mark labels. Set to NULL to inherit from the data's aesthetics. |
bag.linetype , bag.linewidth , bag.colour , bag.color , bag.fill , bag.alpha |
Default aesthetics for bags. Set to |
median.shape , median.stroke , median.size , median.colour , median.color , median.fill , median.alpha |
Default aesthetics for medians. Set to |
fence.linetype , fence.linewidth , fence.colour , fence.color , fence.fill , fence.alpha |
Default aesthetics for fences. Set to |
outlier.shape , outlier.stroke , outlier.size , outlier.colour , outlier.color , outlier.fill , outlier.alpha |
Default aesthetics for outliers. Set to |
new_data |
A list (best structured as a data.frame)
of row ( |
type |
Character value matched to |
point.fill |
Default aesthetics for markers. Set to NULL to inherit from the data's aesthetics. |
isoline_text |
Logical; whether to include text value marks along the isolines. |
snap_rule |
Logical; whether to snap rule segments to grid values. |
vector_labels |
Logical; whether to include labels radiating outward from the vectors. |
A ggproto layer.
Other biplot layers:
biplot-stats
,
stat_referent()
,
stat_rows()
# compute log-ratio analysis of Freestone primary class composition measurements
glass %>%
ordinate(cols = c(SiO2, Al2O3, CaO, FeO, MgO),
model = lra, compositional = TRUE) %>%
confer_inertia("rows") %>%
print() -> glass_lra
# row-principal biplot with ordinate-wise standard deviations
glass_lra %>%
ggbiplot(aes(color = Site), sec.axes = "cols") +
theme_biplot() +
scale_color_brewer(type = "qual", palette = 6) +
geom_cols_text(stat = "chull", aes(label = name), color = "#444444") +
geom_rows_lineranges(fun.data = mean_sdl, linewidth = .75) +
geom_rows_point(alpha = .5) +
ggtitle(
"Row-principal LRA biplot of Freestone glass measurements",
"Ranges 2 sample standard deviations from centroids"
)
# principal components analysis of glass composition measurements
glass[, c(5L, 7L, 8L, 10L, 11L)] %>%
princomp(cor = TRUE) %>%
as_tbl_ord() %>%
cbind_rows(site = glass$Site, form = glass$Form) %>%
augment_ord() %>%
print() -> glass_pca
# note that column standard coordinates are unit vectors
rowSums(get_cols(glass_pca) ^ 2)
# plot column standard coordinates with a unit circle underlaid
glass_pca %>%
ggbiplot(aes(label = name), sec.axes = "cols") +
theme_biplot() +
geom_rows_point(aes(color = site, shape = form), elements = "score") +
geom_unit_circle(alpha = .5, scale.factor = 3) +
geom_cols_vector()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.