Skip to main content

Theme

Struct Theme 

Source
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: usize

Number 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: f64

A 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: bool

Align 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: f64

Line 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: bool

Read 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: bool

Place the tag in the panel’s corner (ggplot2’s plot.tag.location = "panel", #413); default the plot’s.

§strip_placement_outside: bool

Facet strips below / left of a panel sit outside its axis (ggplot2’s strip.placement = "outside", #412); default inside.

§strip_switch_pad: f64

Gap 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: bool

Draw gridlines on top of the data layers (R’s panel.ontop).

§axis_minor_ticks: bool

Draw minor tick marks between major ticks (R’s axis.minor.ticks).

§title_position: TitlePosition

Whether title/subtitle/caption align to the panel or the whole plot (R’s plot.title.position / plot.caption.position).

§tag_position: TagPosition

Corner 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: ElementLine

Month 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: ElementGeom

Geom ink/paper/accent/family palette (ggplot2 4.0’s element_geom, B2-7). Every field None (the default) changes nothing.

§axis_text_x_fit: AxisLabelFit

How an outer x-axis label that would cross the SVG edge is handled (B3-1, D6). Default AxisLabelFit::Reserve.

§axis_text_x_check_overlap: bool

Thin 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

Source

pub fn legend_key_gap_y(&self) -> f64

The gap between two rows of legend keys (legend_key_spacing_y).

Source

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.

Source

pub fn ticks_len_x(&self) -> f64

The x axis’s tick length (axis_ticks_length_x, else the shared one).

Source

pub fn ticks_len_y(&self) -> f64

The y axis’s tick length (axis_ticks_length_y, else the shared one).

Source

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).

Source

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.

Source

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.

Source

pub fn with_primary(self, color: (u8, u8, u8)) -> Self

Set the brand/primary color (builder style).

Source

pub fn set_geom(self, el: ElementGeom) -> Self

Set the geom ink/paper/accent/family palette (B2-7).

Source

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.

Source

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.

Source

pub fn get_axis_line_x(&self) -> &ElementLine

Source

pub fn get_axis_line_y(&self) -> &ElementLine

Source

pub fn get_axis_ticks_x(&self) -> &ElementLine

Source

pub fn get_axis_ticks_y(&self) -> &ElementLine

Source

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.

Source

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.

Source

pub fn get_panel_grid_major_x(&self) -> &ElementLine

Source

pub fn get_panel_grid_major_y(&self) -> &ElementLine

Source

pub fn get_panel_grid_minor_x(&self) -> &ElementLine

Source

pub fn get_panel_grid_minor_y(&self) -> &ElementLine

Source

pub fn get_panel_spacing_x(&self) -> f64

Source

pub fn get_panel_spacing_y(&self) -> f64

Source

pub fn set_axis_text_x(self, el: ElementText) -> Self

Source

pub fn set_axis_text_y(self, el: ElementText) -> Self

Source

pub fn set_axis_title_x(self, el: ElementText) -> Self

Source

pub fn set_axis_title_y(self, el: ElementText) -> Self

Source

pub fn set_axis_line(self, el: ElementLine) -> Self

Source

pub fn set_axis_ticks(self, el: ElementLine) -> Self

Source

pub fn set_panel_background(self, el: ElementRect) -> Self

Source

pub fn set_panel_grid_major(self, el: ElementLine) -> Self

Source

pub fn set_panel_grid_minor(self, el: ElementLine) -> Self

Source

pub fn set_plot_background(self, el: ElementRect) -> Self

Source

pub fn set_legend_position(self, pos: LegendPosition) -> Self

Source

pub fn set_plot_margin(self, margin: Margin) -> Self

Source

pub fn set_title(self, el: ElementText) -> Self

Source

pub fn set_text(self, el: ElementText) -> Self

Source

pub fn set_subtitle(self, el: ElementText) -> Self

Source

pub fn set_caption(self, el: ElementText) -> Self

Source

pub fn set_legend_title(self, el: ElementText) -> Self

Source

pub fn set_legend_text(self, el: ElementText) -> Self

Source

pub fn set_strip_text(self, el: ElementText) -> Self

Source

pub fn set_axis_line_x(self, el: Option<ElementLine>) -> Self

Source

pub fn set_axis_line_y(self, el: Option<ElementLine>) -> Self

Source

pub fn set_axis_ticks_x(self, el: Option<ElementLine>) -> Self

Source

pub fn set_axis_ticks_y(self, el: Option<ElementLine>) -> Self

Source

pub fn set_panel_grid_major_x(self, el: Option<ElementLine>) -> Self

Source

pub fn set_panel_grid_major_y(self, el: Option<ElementLine>) -> Self

Source

pub fn set_panel_grid_minor_x(self, el: Option<ElementLine>) -> Self

Source

pub fn set_panel_grid_minor_y(self, el: Option<ElementLine>) -> Self

Source

pub fn set_panel_border(self, el: ElementLine) -> Self

Source

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.

Source

pub fn set_calendar_month_border(self, el: ElementLine) -> Self

Source

pub fn set_legend_bar_border(self, el: Option<ElementLine>) -> Self

Source

pub fn set_legend_background(self, el: ElementRect) -> Self

Source

pub fn set_legend_key(self, el: ElementRect) -> Self

Source

pub fn set_strip_background(self, el: ElementRect) -> Self

Source

pub fn set_axis_ticks_length(self, val: f64) -> Self

Source

pub fn set_legend_key_width(self, val: f64) -> Self

Source

pub fn set_legend_key_height(self, val: f64) -> Self

Source

pub fn set_legend_spacing(self, val: f64) -> Self

Source

pub fn set_legend_margin(self, margin: Margin) -> Self

Source

pub fn set_panel_spacing(self, val: f64) -> Self

Source

pub fn set_panel_spacing_x(self, val: Option<f64>) -> Self

Source

pub fn set_panel_spacing_y(self, val: Option<f64>) -> Self

Source

pub fn update(self, upd: ThemeUpdate) -> Self

Apply incremental theme modifications. Only fields that are Some in the update are applied.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Theme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V