pub struct Aes {
pub mappings: Vec<AesMapping>,
pub after_scale: Vec<AfterScaleSpec>,
/* private fields */
}Expand description
Builder for aesthetic mappings.
Fields§
§mappings: Vec<AesMapping>§after_scale: Vec<AfterScaleSpec>Post-scale color derivations (after_scale).
Implementations§
Source§impl Aes
impl Aes
pub fn new() -> Self
Sourcepub fn after_scale_fill_from_color(self, lightness: f64) -> Self
pub fn after_scale_fill_from_color(self, lightness: f64) -> Self
Set fill to the mapped color with adjusted lightness (R’s
aes(fill = after_scale(...))). lightness in -1.0..=1.0: positive
lightens toward white, negative darkens toward black.
Sourcepub fn after_scale_color_from_fill(self, lightness: f64) -> Self
pub fn after_scale_color_from_fill(self, lightness: f64) -> Self
Set color to the mapped fill with adjusted lightness — useful for a
darker border around a filled shape (color = after_scale(darken(fill))).
Sourcepub fn stage(self, aesthetic: Aesthetic, start: &str, after_stat: &str) -> Self
pub fn stage(self, aesthetic: Aesthetic, start: &str, after_stat: &str) -> Self
stage(start, after_stat): map aesthetic from start before the stat
and re-map it from after_stat afterwards (R’s stage()).
pub fn x(self, col: &str) -> Self
pub fn y(self, col: &str) -> Self
pub fn color(self, col: &str) -> Self
pub fn fill(self, col: &str) -> Self
pub fn size(self, col: &str) -> Self
pub fn shape(self, col: &str) -> Self
pub fn alpha(self, col: &str) -> Self
pub fn group(self, col: &str) -> Self
pub fn ymin(self, col: &str) -> Self
pub fn ymax(self, col: &str) -> Self
pub fn label(self, col: &str) -> Self
pub fn weight(self, col: &str) -> Self
pub fn xend(self, col: &str) -> Self
pub fn yend(self, col: &str) -> Self
pub fn xmin(self, col: &str) -> Self
pub fn xmax(self, col: &str) -> Self
pub fn angle(self, col: &str) -> Self
pub fn radius(self, col: &str) -> Self
pub fn linetype(self, col: &str) -> Self
Sourcepub fn linewidth(self, col: &str) -> Self
pub fn linewidth(self, col: &str) -> Self
Stroke width for segment/curve/path/line (R’s linewidth).
Sourcepub fn outliers(self, col: &str) -> Self
pub fn outliers(self, col: &str) -> Self
Boxplot stat="identity" outlier values, as a comma list with
optional brackets ("7, 9" or "[7, 9]") (B3-5).
Sourcepub fn tooltip(self, col: &str) -> Self
pub fn tooltip(self, col: &str) -> Self
A custom <title> hover tooltip from col, replacing the geom’s
own. ensure_scale skips it (no scale, no legend): computing stats
drop the column (identity-stat layers keep it), as linetype/alpha
do.
Sourcepub fn fontface(self, col: &str) -> Self
pub fn fontface(self, col: &str) -> Self
Per-row font face for geom_text/geom_label from col (#228, R’s
aes(fontface = ...)): each row’s value is parsed the same way
theme()’s face is ("plain"/"normal", "bold",
"italic"/"oblique", case-insensitive); an unparseable or NA
value falls back to the geom’s own fixed .with_fontface(..). No
scale, no legend (like tooltip).
Sourcepub fn data_attr(self, name: &str, col: &str) -> Self
pub fn data_attr(self, name: &str, col: &str) -> Self
A custom data-<name> attribute on the mark, from col. name must
match [a-z0-9][a-z0-9-]* and not be a name ggplot-rs itself writes
via another mechanism (currently just "part" — see
DrawBackend::set_mark_part); an invalid or reserved name is skipped
with a build warning (surfaced via
GGPlot::aes / layer_aes). A user attr
replaces a built-in of the same name (data-x, data-series,
data-value) — never duplicated.
Sourcepub fn class(self, col: &str) -> Self
pub fn class(self, col: &str) -> Self
CSS class tokens on each mark, from col (#221): the row’s value is
split on whitespace and every token must match
[A-Za-z][A-Za-z0-9_-]*; an invalid token is dropped (with one build
warning per layer), the rest are kept. The tokens are appended to the
mark’s own class="gg-mark gg-<kind>" — there is never a second
class attribute, and never an inline style (so a strict CSP with
no unsafe-inline still holds: style the classes from an external
stylesheet). Read by every geom that reads data_attr,
plus geom_text/geom_label. For one constant class on a whole
layer use GGPlot::layer_svg_attr
("class", "…") instead.
Sourcepub fn group_wrap(self, name: &str, col: &str) -> Self
pub fn group_wrap(self, name: &str, col: &str) -> Self
Wrap marks in caller-named groups (#221): every mark whose row has
the same col value is drawn inside one <g data-<name>="<value>">
— across all layers that map group_wrap with the same name — so
client code can address (or tween) e.g. a diagram node’s box, label
and badge as one element: querySelector('[data-of="node-7"]').
name follows data_attr’s rules
([a-z0-9][a-z0-9-]*, not reserved); a leading data- is accepted
and stripped, so group_wrap("of", …) and group_wrap("data-of", …)
are the same. An invalid name is skipped with a build warning. A row
whose value is NA is drawn ungrouped.
Paint order: a group is placed where its first mark would have
been drawn, and later marks of the same group are appended inside
it. So with a box layer then a label layer, both grouped by node,
the output is <g data-of="a">box-a label-a</g><g data-of="b">box-b label-b</g> — node b’s box now paints over node a’s label,
which only matters if they overlap. Ungrouped marks keep their
positions. SVG backend only; raster backends ignore grouping.
Sourcepub fn xintercept(self, col: &str) -> Self
pub fn xintercept(self, col: &str) -> Self
Data-mapped geom_vline position (one line per row).
Sourcepub fn yintercept(self, col: &str) -> Self
pub fn yintercept(self, col: &str) -> Self
Data-mapped geom_hline position (one line per row).
Sourcepub fn intercept(self, col: &str) -> Self
pub fn intercept(self, col: &str) -> Self
Data-mapped geom_abline intercept (one line per row).
Sourcepub fn after_stat_y(self, col: &str) -> Self
pub fn after_stat_y(self, col: &str) -> Self
Map a stat-computed column to the y aesthetic (e.g., after_stat_y("density")).
Sourcepub fn after_stat_x(self, col: &str) -> Self
pub fn after_stat_x(self, col: &str) -> Self
Map a stat-computed column to the x aesthetic.
Sourcepub fn after_stat_fill(self, col: &str) -> Self
pub fn after_stat_fill(self, col: &str) -> Self
Map a stat-computed column to the fill aesthetic.
Sourcepub fn after_stat_color(self, col: &str) -> Self
pub fn after_stat_color(self, col: &str) -> Self
Map a stat-computed column to the color aesthetic.
Sourcepub fn after_stat_size(self, col: &str) -> Self
pub fn after_stat_size(self, col: &str) -> Self
Map a stat-computed column to the size aesthetic.
Sourcepub fn after_stat_alpha(self, col: &str) -> Self
pub fn after_stat_alpha(self, col: &str) -> Self
Map a stat-computed column to the alpha aesthetic.
Sourcepub fn after_stat_linewidth(self, col: &str) -> Self
pub fn after_stat_linewidth(self, col: &str) -> Self
Map a stat-computed column to the linewidth aesthetic.
Sourcepub fn get_mapping(&self, aes: &Aesthetic) -> Option<&str>
pub fn get_mapping(&self, aes: &Aesthetic) -> Option<&str>
Get the column mapped to a specific aesthetic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Aes
impl RefUnwindSafe for Aes
impl Send for Aes
impl Sync for Aes
impl Unpin for Aes
impl UnsafeUnpin for Aes
impl UnwindSafe for Aes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more