pub struct Theme {Show 79 fields
pub text: ElementText,
pub title: ElementText,
pub axis_text_x: ElementText,
pub axis_text_y: ElementText,
pub axis_title_x: ElementText,
pub axis_title_y: ElementText,
pub axis_line: ElementLine,
pub axis_ticks: ElementLine,
pub panel_background: ElementRect,
pub panel_grid_major: ElementLine,
pub panel_grid_minor: ElementLine,
pub plot_background: ElementRect,
pub legend_position: LegendPosition,
pub plot_margin: Margin,
pub subtitle: ElementText,
pub caption: ElementText,
pub legend_title: ElementText,
pub legend_text: ElementText,
pub strip_text: ElementText,
pub axis_line_x: Option<ElementLine>,
pub axis_line_y: Option<ElementLine>,
pub axis_ticks_x: Option<ElementLine>,
pub axis_ticks_y: Option<ElementLine>,
pub axis_line_x_top: Option<ElementLine>,
pub axis_line_x_bottom: Option<ElementLine>,
pub axis_line_y_left: Option<ElementLine>,
pub axis_line_y_right: Option<ElementLine>,
pub axis_ticks_x_top: Option<ElementLine>,
pub axis_ticks_x_bottom: Option<ElementLine>,
pub axis_ticks_y_left: Option<ElementLine>,
pub axis_ticks_y_right: Option<ElementLine>,
pub panel_grid_major_x: Option<ElementLine>,
pub panel_grid_major_y: Option<ElementLine>,
pub panel_grid_minor_x: Option<ElementLine>,
pub panel_grid_minor_y: Option<ElementLine>,
pub panel_border: ElementLine,
pub legend_background: ElementRect,
pub legend_key: ElementRect,
pub strip_background: ElementRect,
pub axis_ticks_length: f64,
pub axis_text_x_dodge: usize,
pub legend_key_width: f64,
pub legend_key_height: f64,
pub legend_spacing: f64,
pub legend_ticks_length: f64,
pub caption_position: Option<TitlePosition>,
pub legend_location_plot: bool,
pub axis_ticks_length_x: Option<f64>,
pub axis_ticks_length_y: Option<f64>,
pub legend_key_spacing_x: Option<f64>,
pub legend_key_spacing_y: Option<f64>,
pub legend_box_spacing: Option<f64>,
pub legend_box_just: f64,
pub rich_text: bool,
pub tag_location_panel: bool,
pub strip_placement_outside: bool,
pub strip_switch_pad: f64,
pub legend_margin: Margin,
pub panel_spacing: f64,
pub panel_spacing_x: Option<f64>,
pub panel_spacing_y: Option<f64>,
pub primary: Option<(u8, u8, u8)>,
pub aspect_ratio: Option<f64>,
pub panel_ontop: bool,
pub axis_minor_ticks: bool,
pub title_position: TitlePosition,
pub tag_position: TagPosition,
pub legend_direction: Option<LegendDirection>,
pub calendar_month_border: ElementLine,
pub legend_bar_border: Option<ElementLine>,
pub geom: ElementGeom,
pub axis_text_x_fit: AxisLabelFit,
pub axis_text_x_check_overlap: bool,
pub axis_text_x_top: Option<ElementText>,
pub axis_text_y_right: Option<ElementText>,
pub strip_text_x: Option<ElementText>,
pub strip_background_x: Option<ElementRect>,
pub strip_text_y: Option<ElementText>,
pub strip_background_y: Option<ElementRect>,
}Expand description
Complete theme specification for a plot.
Fields§
§text: ElementText§title: ElementText§axis_text_x: ElementText§axis_text_y: ElementText§axis_title_x: ElementText§axis_title_y: ElementText§axis_line: ElementLine§axis_ticks: ElementLine§panel_background: ElementRect§panel_grid_major: ElementLine§panel_grid_minor: ElementLine§plot_background: ElementRect§legend_position: LegendPosition§plot_margin: Margin§subtitle: ElementText§caption: ElementText§legend_title: ElementText§legend_text: ElementText§strip_text: ElementText§axis_line_x: Option<ElementLine>§axis_line_y: Option<ElementLine>§axis_ticks_x: Option<ElementLine>§axis_ticks_y: Option<ElementLine>§axis_line_x_top: Option<ElementLine>One side’s axis line / ticks (ggplot2’s axis.line.x.top,
axis.ticks.y.right, …, #413); None = the axis’s own
(axis_line_x …), then the shared one.
axis_line_x_bottom: Option<ElementLine>§axis_line_y_left: Option<ElementLine>§axis_line_y_right: Option<ElementLine>§axis_ticks_x_top: Option<ElementLine>§axis_ticks_x_bottom: Option<ElementLine>§axis_ticks_y_left: Option<ElementLine>§axis_ticks_y_right: Option<ElementLine>§panel_grid_major_x: Option<ElementLine>§panel_grid_major_y: Option<ElementLine>§panel_grid_minor_x: Option<ElementLine>§panel_grid_minor_y: Option<ElementLine>§panel_border: ElementLine§legend_background: ElementRect§legend_key: ElementRect§strip_background: ElementRect§axis_ticks_length: f64§axis_text_x_dodge: usizeNumber of rows to stagger x-axis tick labels across (R’s
guide_axis(n.dodge = ...)); 1 = no dodging.
legend_key_width: f64§legend_key_height: f64§legend_spacing: f64§legend_ticks_length: f64A colourbar’s tick length (ggplot2’s legend.ticks.length, #413).
caption_position: Option<TitlePosition>What the caption aligns to (ggplot2’s plot.caption.position,
#413); None follows title_position.
legend_location_plot: boolAlign an outside legend with the whole plot instead of the panel
(ggplot2’s legend.location = "plot", #413).
axis_ticks_length_x: Option<f64>One axis’s tick length (ggplot2’s axis.ticks.length.x / .y,
#413); None = axis_ticks_length.
axis_ticks_length_y: Option<f64>§legend_key_spacing_x: Option<f64>Extra gap between legend keys (ggplot2’s legend.key.spacing.x /
.y, #413): x between the keys of a horizontal legend (default
3 × legend_spacing), y between rows (default none).
legend_key_spacing_y: Option<f64>§legend_box_spacing: Option<f64>Gap between the panel and an outside legend (ggplot2’s
legend.box.spacing, #413) — replaces legend_margin’s side that
faces the panel; None keeps it.
legend_box_just: f64Line several legends up along the stack’s cross axis (ggplot2’s
legend.box.just, #413): 0 left / top (the default), 0.5
centre, 1 right / bottom.
rich_text: boolRead titles, axis titles, strip and legend text as a Markdown / HTML
subset (ggtext’s element_markdown(), #413): **bold**, *italic*,
^sup^, ~sub~, <span style='color:…'> — see crate::render::rich.
tag_location_panel: boolPlace the tag in the panel’s corner (ggplot2’s plot.tag.location = "panel", #413); default the plot’s.
strip_placement_outside: boolFacet strips below / left of a panel sit outside its axis
(ggplot2’s strip.placement = "outside", #412); default inside.
strip_switch_pad: f64Gap between an axis and an outside strip (strip.switch.pad.*).
legend_margin: Margin§panel_spacing: f64§panel_spacing_x: Option<f64>§panel_spacing_y: Option<f64>§primary: Option<(u8, u8, u8)>Optional brand color. When set, geoms that draw a single un-mapped series (no color/fill aesthetic) use it as their default instead of the geom’s built-in color. Lets one render process serve multiple tenants’ brands.
aspect_ratio: Option<f64>Fix the panel’s height:width ratio (R’s aspect.ratio). None = free.
panel_ontop: boolDraw gridlines on top of the data layers (R’s panel.ontop).
axis_minor_ticks: boolDraw minor tick marks between major ticks (R’s axis.minor.ticks).
title_position: TitlePositionWhether title/subtitle/caption align to the panel or the whole plot
(R’s plot.title.position / plot.caption.position).
tag_position: TagPositionCorner for the labs(tag) label (R’s plot.tag.position).
legend_direction: Option<LegendDirection>Legend key layout direction; None = auto from legend_position.
calendar_month_border: ElementLineMonth outlines of geom_calendar; ElementLine::blank() hides them.
legend_bar_border: Option<ElementLine>Frame around a continuous colourbar. None keeps the default
(legend_key.color, else dark grey, 0.5 wide); ElementLine::blank()
hides it.
geom: ElementGeomGeom ink/paper/accent/family palette (ggplot2 4.0’s element_geom,
B2-7). Every field None (the default) changes nothing.
axis_text_x_fit: AxisLabelFitHow an outer x-axis label that would cross the SVG edge is handled
(B3-1, D6). Default AxisLabelFit::Reserve.
axis_text_x_check_overlap: boolThin crowded x-axis labels in ggplot2’s check.overlap priority
order (B3-1, D5): off by default, so default output is unaffected.
axis_text_x_top: Option<ElementText>The labels of an x axis drawn on top (ggplot2’s axis.text.x.top,
#413); None = axis_text_x.
axis_text_y_right: Option<ElementText>The labels of a right-hand (secondary) y axis (axis.text.y.right,
#413); None = axis_text_y.
strip_text_x: Option<ElementText>Horizontal (top / bottom) strips’ text and background (ggplot2’s
strip.text.x / strip.background.x, #413); None = strip_text
/ strip_background.
strip_background_x: Option<ElementRect>§strip_text_y: Option<ElementText>Vertical (left / right) strips’ (strip.text.y /
strip.background.y).
strip_background_y: Option<ElementRect>Implementations§
Source§impl Theme
impl Theme
Sourcepub fn legend_key_gap_y(&self) -> f64
pub fn legend_key_gap_y(&self) -> f64
The gap between two rows of legend keys (legend_key_spacing_y).
Sourcepub fn legend_margin_outer(&self) -> Margin
pub fn legend_margin_outer(&self) -> Margin
legend_margin with its panel-facing side replaced by
legend_box_spacing (#413) for the outside legend positions.
Sourcepub fn ticks_len_x(&self) -> f64
pub fn ticks_len_x(&self) -> f64
The x axis’s tick length (axis_ticks_length_x, else the shared one).
Sourcepub fn ticks_len_y(&self) -> f64
pub fn ticks_len_y(&self) -> f64
The y axis’s tick length (axis_ticks_length_y, else the shared one).
Sourcepub fn hide_y_guides(&mut self)
pub fn hide_y_guides(&mut self)
Hide only the y position guides (axis text, title, line, ticks and
the horizontal grid lines) — layout charts with a real x axis but a
meaningless y (geom_timeline).
Sourcepub fn hide_position_guides(&mut self)
pub fn hide_position_guides(&mut self)
Hide the position guides — axis text, titles, lines, ticks and panel
grid — for layout-only charts whose x/y carry no data meaning
(geom_sankey). Backgrounds, legend and titles are untouched.
Sourcepub fn primary_or(&self, fallback: (u8, u8, u8)) -> (u8, u8, u8)
pub fn primary_or(&self, fallback: (u8, u8, u8)) -> (u8, u8, u8)
Resolve the effective series color: the theme’s brand color if set, otherwise the geom’s own default.
Sourcepub fn with_primary(self, color: (u8, u8, u8)) -> Self
pub fn with_primary(self, color: (u8, u8, u8)) -> Self
Set the brand/primary color (builder style).
Sourcepub fn set_geom(self, el: ElementGeom) -> Self
pub fn set_geom(self, el: ElementGeom) -> Self
Set the geom ink/paper/accent/family palette (B2-7).
Sourcepub fn with_ink_paper(self, ink: (u8, u8, u8), paper: (u8, u8, u8)) -> Self
pub fn with_ink_paper(self, ink: (u8, u8, u8), paper: (u8, u8, u8)) -> Self
Set just the geom ink and paper colours (B2-7’s stretch goal),
leaving accent/family as they were.
Sourcepub fn resolve_inheritance(&mut self)
pub fn resolve_inheritance(&mut self)
Resolve R-style element inheritance: text-child elements still at the
default family/color inherit them from the root text element, so
setting only theme.text.family restyles every text element. Child
elements that already override a property keep it. Called once before
rendering.
pub fn get_axis_line_x(&self) -> &ElementLine
pub fn get_axis_line_y(&self) -> &ElementLine
pub fn get_axis_ticks_x(&self) -> &ElementLine
pub fn get_axis_ticks_y(&self) -> &ElementLine
Sourcepub fn axis_line_at(&self, side: AxisSide) -> &ElementLine
pub fn axis_line_at(&self, side: AxisSide) -> &ElementLine
The axis line on one side of the panel (#413): its side’s own
element, else the x / y one, else axis_line.
Sourcepub fn axis_ticks_at(&self, side: AxisSide) -> &ElementLine
pub fn axis_ticks_at(&self, side: AxisSide) -> &ElementLine
The axis ticks on one side of the panel (#413), inheriting like
Theme::axis_line_at.
pub fn get_panel_grid_major_x(&self) -> &ElementLine
pub fn get_panel_grid_major_y(&self) -> &ElementLine
pub fn get_panel_grid_minor_x(&self) -> &ElementLine
pub fn get_panel_grid_minor_y(&self) -> &ElementLine
pub fn get_panel_spacing_x(&self) -> f64
pub fn get_panel_spacing_y(&self) -> f64
pub fn set_axis_text_x(self, el: ElementText) -> Self
pub fn set_axis_text_y(self, el: ElementText) -> Self
pub fn set_axis_title_x(self, el: ElementText) -> Self
pub fn set_axis_title_y(self, el: ElementText) -> Self
pub fn set_axis_line(self, el: ElementLine) -> Self
pub fn set_axis_ticks(self, el: ElementLine) -> Self
pub fn set_panel_background(self, el: ElementRect) -> Self
pub fn set_panel_grid_major(self, el: ElementLine) -> Self
pub fn set_panel_grid_minor(self, el: ElementLine) -> Self
pub fn set_plot_background(self, el: ElementRect) -> Self
pub fn set_legend_position(self, pos: LegendPosition) -> Self
pub fn set_plot_margin(self, margin: Margin) -> Self
pub fn set_title(self, el: ElementText) -> Self
pub fn set_text(self, el: ElementText) -> Self
pub fn set_subtitle(self, el: ElementText) -> Self
pub fn set_caption(self, el: ElementText) -> Self
pub fn set_legend_title(self, el: ElementText) -> Self
pub fn set_legend_text(self, el: ElementText) -> Self
pub fn set_strip_text(self, el: ElementText) -> Self
pub fn set_axis_line_x(self, el: Option<ElementLine>) -> Self
pub fn set_axis_line_y(self, el: Option<ElementLine>) -> Self
pub fn set_axis_ticks_x(self, el: Option<ElementLine>) -> Self
pub fn set_axis_ticks_y(self, el: Option<ElementLine>) -> Self
pub fn set_panel_grid_major_x(self, el: Option<ElementLine>) -> Self
pub fn set_panel_grid_major_y(self, el: Option<ElementLine>) -> Self
pub fn set_panel_grid_minor_x(self, el: Option<ElementLine>) -> Self
pub fn set_panel_grid_minor_y(self, el: Option<ElementLine>) -> Self
pub fn set_panel_border(self, el: ElementLine) -> Self
Sourcepub fn legend_bar_border_line(&self) -> ElementLine
pub fn legend_bar_border_line(&self) -> ElementLine
The effective colourbar frame: legend_bar_border,
else legend_key.color (dark grey when unset), 0.5 wide.
pub fn set_calendar_month_border(self, el: ElementLine) -> Self
pub fn set_legend_bar_border(self, el: Option<ElementLine>) -> Self
pub fn set_legend_background(self, el: ElementRect) -> Self
pub fn set_legend_key(self, el: ElementRect) -> Self
pub fn set_strip_background(self, el: ElementRect) -> Self
pub fn set_axis_ticks_length(self, val: f64) -> Self
pub fn set_legend_key_width(self, val: f64) -> Self
pub fn set_legend_key_height(self, val: f64) -> Self
pub fn set_legend_spacing(self, val: f64) -> Self
pub fn set_legend_margin(self, margin: Margin) -> Self
pub fn set_panel_spacing(self, val: f64) -> Self
pub fn set_panel_spacing_x(self, val: Option<f64>) -> Self
pub fn set_panel_spacing_y(self, val: Option<f64>) -> Self
Sourcepub fn update(self, upd: ThemeUpdate) -> Self
pub fn update(self, upd: ThemeUpdate) -> Self
Apply incremental theme modifications.
Only fields that are Some in the update are applied.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
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