Skip to main content

GGPlot

Struct GGPlot 

Source
pub struct GGPlot { /* private fields */ }
Expand description

The top-level plot specification — builder pattern.

Implementations§

Source§

impl GGPlot

Source

pub fn stat_qq(self, distribution: QQDistribution) -> Self

QQ points of y against a theoretical distribution (ggplot2’s stat_qq(distribution = …, dparams = …)): x = quantiles at R’s ppoints(n), y = the sorted sample, per group / panel.

Source

pub fn stat_qq_line(self, distribution: QQDistribution) -> Self

QQ reference line through the sample / theoretical 1st and 3rd quartiles (ggplot2’s stat_qq_line), for any distribution.

Source

pub fn stat_qq_band(self, band: StatQQBand) -> Self

QQ confidence envelope (qqplotr’s stat_qq_band): pointwise normal-theory or KS band around the quartile line, drawn as a ribbon. Add it before geom_qq so the points sit on top.

Source

pub fn geom_qq_band(self) -> Self

stat_qq_band with the default 95% pointwise band against the standard normal.

Source

pub fn geom_qq_band_with(self, geom: GeomQQBand, band: StatQQBand) -> Self

A QQ band with custom fill / alpha.

Source

pub fn stat_cooks_contour(self, p: usize, levels: &[f64]) -> Self

Cook’s-distance contours for a residuals-vs-leverage plot (x = leverage, y = standardized residual), as in R’s plot.lm(which = 5): dashed curves ±√(level · p · (1 − h) / h) for a model with p parameters, clipped to the panel, labelled with the level, in every facet panel. They don’t train the scales.

let obs: Vec<(String, Vec<Value>)> = vec![
    ("leverage".into(), vec![Value::Float(0.05), Value::Float(0.3)]),
    ("std_residual".into(), vec![Value::Float(-1.2), Value::Float(2.1)]),
];
let svg = GGPlot::new(obs)
    .aes(Aes::new().x("leverage").y("std_residual"))
    .geom_point()
    .stat_cooks_contour(3, &[0.5, 1.0])
    .render_svg_native()
    .unwrap();
assert!(svg.contains("Cook&#39;s distance = 0.5"));
Source

pub fn geom_cooks_contour_with(self, geom: GeomCooksContour) -> Self

Cook’s-distance contours with custom styling / leverage range.

Source

pub fn geom_stepribbon(self) -> Self

Step ribbon between ymin and ymax (pammtools’ geom_stepribbon, direction = "hv"): the confidence band of a Kaplan–Meier curve.

Source

pub fn geom_stepribbon_with(self, geom: GeomStepribbon) -> Self

Step ribbon with custom fill / alpha / direction (Hv, Vh, Mid).

Source

pub fn stat_ecdf(self) -> Self

Empirical CDF of x as a step line (ggplot2’s stat_ecdf()), one per group, padded to the panel edges.

Source

pub fn stat_ecdf_band(self, level: f64) -> Self

Simultaneous DKW confidence band for the ECDF of x at level (F̂ ± √(ln(2/(1−level))/(2n)), clamped to [0, 1]) as a step ribbon. Add it before stat_ecdf so the line is on top.

Source

pub fn geom_censor_marks(self, censor_col: &str) -> Self

Censor marks (+) at the rows whose censor_col is > 0 / true, at the layer’s x (time) and y (survival) — e.g. a Kaplan–Meier table with an n_censor column. Coloured like the curves when the plot maps color.

Source

pub fn geom_censor_marks_with( self, geom: GeomCensorMarks, censor_col: &str, ) -> Self

Censor marks with custom size / colour / shape.

Source

pub fn geom_errorbarh(self) -> Self

Horizontal error bars from xmin to xmax at y.

Source

pub fn geom_errorbarh_with(self, geom: GeomErrorbarh) -> Self

Horizontal error bars with custom styling.

Source§

impl GGPlot

Source

pub fn new(data: impl GGData) -> Self

Create a new plot with the given data source.

Never panics on malformed input: e.g. column-oriented data whose columns have different lengths is padded with NA and reported as a GGError::ValidationError by try_build and the render_*/save* methods.

Source

pub fn aes(self, mapping: Aes) -> Self

Set the plot-level aesthetic mapping.

Source

pub fn geom_point(self) -> Self

Source

pub fn geom_point_with(self, geom: GeomPoint) -> Self

Source

pub fn geom_line(self) -> Self

Source

pub fn geom_line_with(self, geom: GeomLine) -> Self

Source

pub fn geom_bar(self) -> Self

Source

pub fn geom_bar_with(self, geom: GeomBar) -> Self

Source

pub fn geom_histogram(self) -> Self

Source

pub fn geom_histogram_with(self, geom: GeomHistogram) -> Self

Source

pub fn geom_boxplot(self) -> Self

Source

pub fn geom_boxplot_with(self, geom: GeomBoxplot) -> Self

Source

pub fn geom_smooth(self) -> Self

Source

pub fn geom_smooth_with(self, geom: GeomSmooth) -> Self

Source

pub fn geom_col(self) -> Self

Source

pub fn geom_col_with(self, geom: GeomCol) -> Self

Source

pub fn geom_hline(self, yintercept: f64) -> Self

Horizontal reference line at a constant yintercept. Like ggplot2 the intercept trains the y scale (the line is always visible) and the line appears in every facet panel.

Source

pub fn geom_hline_with(self, geom: GeomHline) -> Self

Add a horizontal reference line with custom styling (color/linetype/width).

Source

pub fn geom_hline_aes(self, mapping: Aes) -> Self

Data-mapped horizontal lines (ggplot2’s geom_hline(aes(yintercept = …))): one line per row of the layer data (the plot data unless layer_data follows), per facet panel, styled by any color/linetype/alpha in mapping. The plot-level mapping is not inherited.

let thresholds: Vec<(String, Vec<Value>)> = vec![
    ("bound".into(), vec![Value::Float(-0.2), Value::Float(0.2)]),
];
let svg = GGPlot::new(vec![
        ("lag".to_string(), vec![Value::Float(1.0), Value::Float(2.0)]),
        ("acf".to_string(), vec![Value::Float(0.5), Value::Float(0.1)]),
    ])
    .aes(Aes::new().x("lag").y("acf"))
    .geom_col()
    .geom_hline_aes(Aes::new().yintercept("bound"))
    .layer_data(thresholds)
    .render_svg_native()
    .unwrap();
assert!(svg.contains("data-value=\"0.2\""));
Source

pub fn geom_hline_aes_with(self, geom: GeomHline, mapping: Aes) -> Self

geom_hline_aes with custom default styling.

Source

pub fn geom_vline(self, xintercept: f64) -> Self

Vertical reference line at a constant xintercept (trains the x scale, appears in every panel).

Source

pub fn geom_vline_with(self, geom: GeomVline) -> Self

Add a vertical reference line with custom styling (color/linetype/width).

Source

pub fn geom_vline_aes(self, mapping: Aes) -> Self

Data-mapped vertical lines (aes(xintercept = …)), one per row; see geom_hline_aes.

Source

pub fn geom_vline_aes_with(self, geom: GeomVline, mapping: Aes) -> Self

geom_vline_aes with custom default styling.

Source

pub fn geom_abline(self, slope: f64, intercept: f64) -> Self

Line y = intercept + slope · x in data space, clipped to the panel. It does not train any scale (as in ggplot2).

Source

pub fn geom_abline_with(self, geom: GeomAbline) -> Self

Add a slope/intercept reference line with custom styling.

Source

pub fn geom_abline_aes(self, mapping: Aes) -> Self

Data-mapped ablines (aes(slope = …, intercept = …)), one per row; a missing aesthetic defaults to slope 1 / intercept 0.

Source

pub fn geom_abline_aes_with(self, geom: GeomAbline, mapping: Aes) -> Self

geom_abline_aes with custom default styling.

Source

pub fn geom_text(self) -> Self

Source

pub fn geom_text_with(self, geom: GeomText) -> Self

Source

pub fn geom_bracket(self, xmin: &str, xmax: &str, y: f64, label: &str) -> Self

Draw a significance bracket over the plot (ggpubr::geom_bracket): a bar spanning the categorical positions xmin..xmax at height y, captioned with label (e.g. a p-value or significance stars). Pairs with a boxplot and stat_compare_means.

Source

pub fn geom_bracket_many( self, geom: GeomBracket, brackets: &[(&str, &str, f64, &str)], ) -> Self

Draw several significance brackets at once with a configured GeomBracket. Each tuple is (xmin, xmax, y, label).

Source

pub fn geom_bracket_table(self, table: impl GGData, spec: BracketTable) -> Self

Significance brackets from a precomputed test table (ggpubr’s stat_pvalue_manual / geom_bracket(data = …)) — e.g. the anofox test contract output (group1, group2, p_adj/p_value, optional y_position, label). No test is recomputed. See BracketTable for the column rules, label templates ("p = {p_adj}", "{p.signif}") and the automatic stacking of rows without a y_position. Rows that cannot be drawn are dropped with a build warning.

Source

pub fn geom_text_repel(self) -> Self

Text labels that repel each other and their points (ggrepel::geom_text_repel) — deterministic (seeded) layout; see GeomTextRepel. Requires x, y and label.

Source

pub fn geom_text_repel_with(self, geom: GeomTextRepel) -> Self

geom_text_repel with a configured geom (padding, nudge, max_overlaps, seed, …).

Source

pub fn geom_label_repel(self) -> Self

Boxed labels that repel each other and their points (ggrepel::geom_label_repel).

Source

pub fn geom_label_repel_with(self, geom: GeomLabelRepel) -> Self

geom_label_repel with a configured geom.

Source

pub fn geom_label(self) -> Self

Source

pub fn geom_label_with(self, geom: GeomLabel) -> Self

Source

pub fn geom_area(self) -> Self

Source

pub fn geom_area_with(self, geom: GeomArea) -> Self

Source

pub fn geom_ribbon(self) -> Self

Source

pub fn geom_ribbon_with(self, geom: GeomRibbon) -> Self

Source

pub fn geom_errorbar(self) -> Self

Source

pub fn geom_errorbar_with(self, geom: GeomErrorbar) -> Self

Source

pub fn geom_segment(self) -> Self

Source

pub fn geom_segment_with(self, geom: GeomSegment) -> Self

Source

pub fn geom_density(self) -> Self

Source

pub fn geom_density_with(self, geom: GeomDensity) -> Self

Source

pub fn geom_rug(self) -> Self

Source

pub fn geom_rug_with(self, geom: GeomRug) -> Self

Source

pub fn geom_jitter(self) -> Self

Source

pub fn geom_jitter_with(self, geom: GeomJitter) -> Self

Source

pub fn geom_path(self) -> Self

Source

pub fn geom_path_with(self, geom: GeomPath) -> Self

Source

pub fn stat_ellipse(self) -> Self

Add a confidence-ellipse layer (default 95%) as a path per group.

Source

pub fn stat_ellipse_level(self, level: f64) -> Self

Add a confidence-ellipse layer at the given level (0, 1).

Source

pub fn geom_step(self) -> Self

Source

pub fn geom_step_with(self, geom: GeomStep) -> Self

Source

pub fn geom_freqpoly(self) -> Self

Source

pub fn geom_freqpoly_with(self, geom: GeomFreqpoly) -> Self

Source

pub fn geom_linerange(self) -> Self

Source

pub fn geom_linerange_with(self, geom: GeomLinerange) -> Self

Source

pub fn geom_pointrange(self) -> Self

Source

pub fn geom_pointrange_with(self, geom: GeomPointrange) -> Self

Source

pub fn geom_crossbar(self) -> Self

Source

pub fn geom_crossbar_with(self, geom: GeomCrossbar) -> Self

Source

pub fn geom_spoke(self) -> Self

Source

pub fn geom_spoke_with(self, geom: GeomSpoke) -> Self

Source

pub fn geom_rect(self) -> Self

Source

pub fn geom_rect_with(self, geom: GeomRect) -> Self

Source

pub fn geom_tile(self) -> Self

Source

pub fn geom_tile_with(self, geom: GeomTile) -> Self

Source

pub fn geom_raster(self) -> Self

Dense regular grid of filled cells (heatmap/raster) from x, y, fill.

Source

pub fn geom_raster_with(self, geom: GeomRaster) -> Self

Source

pub fn geom_polygon(self) -> Self

Source

pub fn geom_polygon_with(self, geom: GeomPolygon) -> Self

Source

pub fn geom_curve(self) -> Self

Source

pub fn geom_curve_with(self, geom: GeomCurve) -> Self

Source

pub fn geom_violin(self) -> Self

Source

pub fn geom_violin_with(self, geom: GeomViolin) -> Self

Source

pub fn geom_dotplot(self) -> Self

Source

pub fn geom_dotplot_with(self, geom: GeomDotplot) -> Self

Source

pub fn geom_qq(self) -> Self

Source

pub fn geom_qq_with(self, geom: GeomQQ) -> Self

Source

pub fn geom_qq_line(self) -> Self

Source

pub fn geom_qq_line_with(self, geom: GeomQQLine) -> Self

Source

pub fn geom_bin2d(self) -> Self

Source

pub fn geom_bin2d_with(self, geom: GeomBin2d) -> Self

Source

pub fn geom_hex(self) -> Self

Source

pub fn geom_hex_with(self, geom: GeomHex) -> Self

Source

pub fn geom_count(self) -> Self

Source

pub fn geom_count_with(self, geom: GeomCount) -> Self

Source

pub fn geom_contour(self) -> Self

Source

pub fn geom_contour_with(self, geom: GeomContour) -> Self

Source

pub fn geom_contour_filled(self) -> Self

Filled contour bands from gridded (x, y, z) data — draws polygons filled by band level. Pair with a continuous fill scale (e.g. scale_fill_viridis_c).

Source

pub fn geom_density2d(self) -> Self

Source

pub fn geom_density2d_with(self, geom: GeomDensity2d) -> Self

Source

pub fn geom_waterfall(self) -> Self

Waterfall (bridge) chart: map x (steps, in data order) and y (each step’s change). Bars float from the running total and are filled by direction (Increase / Decrease / Total, with a legend); dashed connectors join consecutive bars. See geom_waterfall_with for subtotals and a closing total.

Source

pub fn geom_waterfall_with(self, geom: GeomWaterfall) -> Self

geom_waterfall with explicit colours, totals (subtotal x levels) and final_total. Unless fill is already mapped at plot level, the layer maps after_stat(fill = direction); unless a fill scale is already set, a manual fill scale with the geom’s up/down/total colours is added (a later scale_fill_* call replaces it).

Source

pub fn geom_pareto(self) -> Self

Pareto chart: map x (categories) and y (values, summed per category). Bars are sorted descending and a cumulative line with points rises to the grand total, read against a 0–100 % right axis.

Source

pub fn geom_pareto_with(self, geom: GeomPareto) -> Self

geom_pareto with explicit styling, sorting or a threshold line. Unless a y scale is already set, a continuous y scale with a SecAxis::percent_of_max secondary axis (“Cumulative %”) is added; a later scale_y_continuous replaces it.

Source

pub fn geom_sankey(self) -> Self

Sankey diagram from an edge list: map from, to and optionally weight (Aes::new().from("src").to("dst").weight("flow")). Nodes are placed in columns by their depth, sized by their flow and coloured by name through the fill scale (no legend — nodes are labelled); links take their source’s colour. Axes and grid are hidden, whatever the theme.

Source

pub fn geom_sankey_with(self, geom: GeomSankey) -> Self

geom_sankey with explicit layout and styling.

Source

pub fn geom_chord(self) -> Self

Chord diagram / dependency wheel from an edge list: map from, to and optionally weight. Each node is an arc sized by its total flow (in + out); each link a ribbon through the centre, coloured by its source. Nodes are coloured by name through the fill scale (no legend — they are labelled); axes and grid are hidden and the panel is kept square so the circle stays round.

Source

pub fn geom_chord_with(self, geom: GeomChord) -> Self

geom_chord with explicit padding and styling.

Source

pub fn geom_arcdiagram(self) -> Self

Arc diagram from an edge list: map from, to and optionally weight. Nodes sit on a line (sized by total flow), links are arcs whose width is their weight. Coloured by node name through the fill scale (no legend — nodes are labelled); axes and grid are hidden.

Source

pub fn geom_arcdiagram_with(self, geom: GeomArcdiagram) -> Self

geom_arcdiagram with explicit ordering, direction and styling.

Source

pub fn geom_treemap(self) -> Self

Squarified treemap: map weight (tile area) and optionally subgroup (tiles nest inside group rectangles), fill and label (Aes::new().weight("sales").subgroup("region").label("country")). When subgroup is mapped at plot level and fill is not, tiles are filled by subgroup. The panel aspect matches the layout so tiles come out square; the position scales get no expansion and the axes and grid are hidden.

Source

pub fn geom_treemap_with(self, geom: GeomTreemap) -> Self

geom_treemap with explicit layout and styling.

Source

pub fn geom_sunburst<S: Into<String>>( self, levels: impl IntoIterator<Item = S>, ) -> Self

Sunburst over the hierarchy columns levels (outermost first), sized by weight (1 per row when unmapped): concentric rings, one per level, each node’s angle ∝ its value and nested in its parent’s. Sets coord_polar, colours each branch by its top-level ancestor (lighter further out; no legend — sectors are labelled), drops scale expansion and hides the position guides.

Source

pub fn geom_icicle<S: Into<String>>( self, levels: impl IntoIterator<Item = S>, ) -> Self

Icicle chart over levels: the partition of geom_sunburst in Cartesian coordinates, root level on top.

Source

pub fn geom_partition_with(self, geom: GeomPartition) -> Self

A partition layer with explicit settings (sunburst under coord_polar, icicle otherwise); same defaults as the shortcuts except the coordinate system, which is left as is.

Source

pub fn geom_funnel(self) -> Self

Funnel chart: map x (stage, in data order; repeats are summed) and y (value). Equal-height stages whose width is proportional to the value, each tapering to the next; labels show the value and the conversion from the first stage. Stages are filled by name (no legend); axes and grid are hidden. See GeomFunnel::silhouette for the Highcharts-style fixed shape.

Source

pub fn geom_pyramid(self) -> Self

Pyramid chart: apex on top, stage heights proportional to the values.

Source

pub fn geom_funnel_with(self, geom: GeomFunnel) -> Self

geom_funnel with an explicit shape and styling.

Source

pub fn geom_stream(self) -> Self

Streamgraph: geom_area stacked around a wiggle-minimising baseline (StackOffset::Wiggle). Map x, y (non-negative) and fill (the series). For a symmetric ThemeRiver use .geom_area().position(position_stack().with_offset(StackOffset::Silhouette)).

Source

pub fn geom_lollipop(self) -> Self

Lollipop chart: a stem from 0 to y capped with a dot, per x (coord_flip for horizontal lollipops).

Source

pub fn geom_lollipop_with(self, geom: GeomLollipop) -> Self

Source

pub fn geom_dumbbell(self) -> Self

Dumbbell chart: a segment from ymin to ymax per x, with a dot at each end (low / high colours); coord_flip for the usual horizontal layout.

Source

pub fn geom_dumbbell_with(self, geom: GeomDumbbell) -> Self

Source

pub fn geom_bullet(self, geom: GeomBullet) -> Self

Bullet chart (horizontal): map x (KPI) and y (actual); configure the target column and range bands on the geom, e.g. GeomBullet::default().with_target("goal").with_ranges([60.0, 80.0, 100.0]). Sets coord_flip; use geom_bullet_vertical for upright bullets.

Source

pub fn geom_bullet_vertical(self, geom: GeomBullet) -> Self

geom_bullet without the flip (vertical bars).

Source

pub fn geom_waffle(self, rows: usize) -> Self

Waffle chart: map fill (category) and weight (units per row); units fill a grid rows high, one contiguous block per category. Axes and grid are hidden; units stay square at any panel aspect.

Source

pub fn geom_parliament(self, rows: usize) -> Self

Parliament (hemicycle) chart: map fill (party) and weight (seats); seats on concentric arcs, parties left to right in data order. rows = 0 picks the number of arcs from the seat count.

Source

pub fn geom_waffle_with(self, geom: GeomWaffle) -> Self

A waffle / parliament layer with explicit settings.

Source

pub fn geom_packed_bubble(self) -> Self

Packed bubble chart: circles with area ∝ weight, packed without overlap; with subgroup they cluster per group (outlined). Fills by subgroup when subgroup is mapped at plot level and fill is not. The panel is square and the axes and grid are hidden.

Source

pub fn geom_packed_bubble_with(self, geom: GeomPackedBubble) -> Self

geom_packed_bubble with explicit styling.

Source

pub fn geom_network(self) -> Self

Network graph from an edge list: map from, to and optionally weight. Force-directed layout (seeded, deterministic), edges with width ∝ weight, nodes sized by degree and labelled. Square panel, axes and grid hidden. See GeomNetwork for directed edges, other layouts and colouring by component.

Source

pub fn geom_network_with(self, geom: GeomNetwork) -> Self

geom_network with explicit settings.

Source

pub fn geom_tree(self) -> Self

Tree diagram from parent → child links: map from (parent) and to (child). Tidy layout (leaves evenly spaced, parents centred over their children), top-down with curved links. See GeomTree::org_chart and other orientations via geom_tree_with. Axes and grid are hidden.

Source

pub fn geom_dendrogram(self) -> Self

Dendrogram from dendrogram_links output (from, to, height): step links at the merge heights, leaves labelled.

Source

pub fn geom_tree_with(self, geom: GeomTree) -> Self

A tree layer with explicit layout and styling.

Source

pub fn geom_venn(self) -> Self

Area-proportional Venn / Euler diagram: map sets ("A", "B", "A&B", … — venn.js-style inclusive sizes) and weight (size). Exact for two and three sets’ pairwise overlaps, approximate beyond. Circles are filled by set name (no legend — regions are labelled); square panel, axes and grid hidden.

Source

pub fn geom_venn_with(self, geom: GeomVenn) -> Self

geom_venn with explicit styling.

Source

pub fn geom_wordcloud(self) -> Self

Word cloud: map label (word) and weight (frequency); optionally color. Largest words placed first along a spiral from the centre, no overlaps, deterministic; words that don’t fit are dropped. Axes and grid are hidden.

Source

pub fn geom_wordcloud_with(self, geom: GeomWordcloud) -> Self

geom_wordcloud with explicit sizes, rotation share, seed and palette.

Source

pub fn geom_variwide(self) -> Self

Variwide chart: map x (category), y (height) and weight (bar width). Unless an x scale is set, the x axis is continuous over the column layout with each category named under its column (computed from the plot data, so map x/weight at plot level).

Source

pub fn geom_marimekko(self) -> Self

Marimekko (mosaic) chart: map x (column), fill (segment) and weight (value). Column widths are their totals’ shares, segments their share of the column (y axis 0–100 %).

Source

pub fn geom_marimekko_with(self, geom: GeomMarimekko) -> Self

A variwide / Marimekko layer with explicit settings.

Source

pub fn geom_timeline(self) -> Self

Timeline: map x (event time, e.g. a date), label, and optionally xend (span end) and color. Events sit on a central baseline with boxed labels stacked on alternating levels so they never overlap; the y axis and horizontal grid are hidden.

Source

pub fn geom_timeline_with(self, geom: GeomTimeline) -> Self

geom_timeline with explicit styling.

Source

pub fn geom_xrange(self) -> Self

X-range / Gantt chart: map y (task), xmin (start) and xmax (end), optionally fill. Zero-length tasks are milestones (diamonds). Unless a y scale is set, tasks read top to bottom in data order (from the plot data). See GeomXrange for progress and dependency arrows.

Source

pub fn geom_xrange_with(self, geom: GeomXrange) -> Self

geom_xrange with progress / dependency columns.

Source

pub fn geom_tilemap(self, shape: TileShape) -> Self

Tile-grid cartogram: map x (grid column), y (grid row, 0 at the top), fill and label; one equal tile per row (see us_state_grid for a ready US layout). Axes and grid are hidden.

Source

pub fn geom_tilemap_with(self, geom: GeomTilemap) -> Self

geom_tilemap with explicit styling.

Source

pub fn geom_windbarb(self, geom: GeomWindbarb) -> Self

Wind barbs: map x (and optionally y), and name the speed (knots, or m/s via .meters_per_second()) and direction (degrees the wind comes from) columns: geom_windbarb(GeomWindbarb::new("speed", "dir")).

Source

pub fn geom_variable_pie(self) -> Self

Variable-radius pie (Highcharts variablepie): map y (wedge angle), radius (wedge length) and fill (category), optionally label. Square panel, axes and grid hidden.

Source

pub fn geom_variable_pie_with(self, geom: GeomVariablePie) -> Self

geom_variable_pie with explicit settings (e.g. a donut inner).

Source

pub fn geom_hlc(self) -> Self

HLC bars: a high–low bar with a close tick (no open needed); map x and high/low/close.

Source

pub fn geom_heikin_ashi(self) -> Self

Heikin-Ashi candles: geom_candlestick over the Heikin-Ashi transform of the OHLC values (StatHeikinAshi).

Source

pub fn geom_renko(self, box_size: f64) -> Self

Renko chart: map y to the price (rows in time order); a brick of box_size per full move, reversals after two boxes. The x axis counts bricks.

Source

pub fn geom_point_figure(self, box_size: f64, reversal: usize) -> Self

Point-and-figure chart: map y to the price (rows in time order); X columns rise, O columns fall, a column reverses after reversal boxes of box_size. The x axis counts columns.

Source

pub fn geom_flags(self) -> Self

Event flags: map x and label (usually as a layer with its own layer_data); flags stand on the x axis, or on a series with GeomFlags::on_series. Flags at the same x stack.

Source

pub fn geom_flags_with(self, geom: GeomFlags) -> Self

Source

pub fn geom_candlestick(self) -> Self

Candlestick chart: map x and open/high/low/close (Aes::new().x("date").open("o").high("h").low("l").close("c")).

Source

pub fn geom_candlestick_with(self, geom: GeomCandlestick) -> Self

Source

pub fn geom_ohlc(self) -> Self

OHLC bar chart (high–low bar with open/close ticks); same aesthetics as geom_candlestick.

Source

pub fn geom_ohlc_with(self, geom: GeomOhlc) -> Self

Source

pub fn geom_calendar(self) -> Self

Calendar heatmap (GitHub/ECharts style): the plot’s x (a date — DateTime, epoch seconds or "YYYY-MM-DD") is laid out as week columns × weekday rows (Sunday on top) via StatCalendar, coloured by fill, with month labels along x, Mon/Wed/Fri along y, month boundary outlines and square cells. Spans over MAX_CALENDAR_YEARS are clipped to the most recent years (with a build warning). Uses the plot-level data and x mapping.

Source

pub fn geom_calendar_with(self, tile: GeomTile, monday_first: bool) -> Self

geom_calendar with a custom cell style and optionally Monday-first weeks.

Source

pub fn geom_blank(self) -> Self

Source

pub fn stat(self, stat: impl Stat + 'static) -> Self

Override the stat for the most recently added layer.

Source

pub fn position(self, pos: impl Position + 'static) -> Self

Override the position for the most recently added layer.

Source

pub fn layer_data(self, data: impl GGData) -> Self

Override the data for the most recently added layer.

Source

pub fn layer_aes(self, mapping: Aes) -> Self

Override the aesthetic mapping for the most recently added layer.

Source

pub fn tooltip(self, template: &str) -> Self

A {column} tooltip template for the most recently added layer (B2-5), replacing its default <title>. Each placeholder is filled from the built layer data (so it can reference a stat-computed column, e.g. a hex’s count) at that row, formatted through the column’s scale when it has one (Scale::format_value) — the same data-fvalue logic, but written into the tooltip text. A column that doesn’t exist on this layer renders as empty, not literally {column}. {{/}} are literal braces. The result is escaped the same way any other tooltip is — this is plain text, not markup.

Source

pub fn show_legend(self, show: bool) -> Self

Control whether the most recently added layer contributes to the legend. true = always show, false = always hide, default (None) = auto.

Source

pub fn decorative(self) -> Self

Mark the most recently added layer as purely decorative (#161): its drawn marks keep their own visual style but carry no per-mark metadata — no <title>, no data-x/data-series/data-value/ data-fvalue, and no data_attr attributes — so an SVG consumer that treats “has a non-empty <title>” as “is a selectable data point” doesn’t pick it up. Meant for a layer that annotates another layer’s mark rather than drawing data in its own right (e.g. a boxplot’s own mean dot, drawn by a separate geom_point layer purely to mark the spot the box’s own tooltip already names). Each mark also carries data-part="decorative" and aria-hidden="true" (data-geom still names the real geom), so a consumer can select decorative marks positively rather than only infer them from what they lack. Their class is gg-mark gg-decorative, not the geom’s own (gg-point, gg-line, …).

A .tooltip(...) template on a decorative layer has no visible effect — the geom’s marks carry no tooltip regardless — and warns, like the existing has-no-effect warning for a geom that doesn’t read tooltips at all.

A decorative layer also defaults to hidden in the legend (it’s annotating, not its own series), unless show_legend(true) is called — before or after decorative() — to opt back in; an explicit show_legend(false) is left untouched either way.

Source

pub fn layer_svg_attr( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Add one SVG attribute to every mark of the most recently added layer (#221) — e.g. to make a label layer drawn over node boxes inert, so hover/click and screen readers pass through to the box below:

let svg = GGPlot::new(data)
    .aes(Aes::new().x("x").y("y").label("l"))
    .geom_text()
    .layer_svg_attr("aria-hidden", "true")
    .layer_svg_attr("pointer-events", "none")
    .layer_svg_attr("class", "node-label")
    .render_svg_native_with_size(200, 200)
    .unwrap();
assert!(svg.contains(r#"aria-hidden="true" pointer-events="none""#));

The allow-list is deliberately small: class (space-separated tokens, each [A-Za-z][A-Za-z0-9_-]*, appended to the mark’s own gg-mark gg-<kind> class; invalid tokens are dropped), aria-hidden ("true"/"false"), pointer-events (an SVG keyword such as "none"), and data-* (Aes::data_attr‘s name rules; a row’s own data_attr of the same name wins). Anything else — in particular style and on* handlers, so a strict CSP without unsafe-inline still holds — is ignored with a build warning, as is a bad value or a call before any layer. A later call with the same name replaces the earlier value. Values are escaped on output. For a per-row class use Aes::class; to wrap several layers’ marks per key in one <g>, Aes::group_wrap. SVG backend only.

Source

pub fn layer_svg_attrs<N: Into<String>, V: Into<String>>( self, attrs: impl IntoIterator<Item = (N, V)>, ) -> Self

layer_svg_attr for several attributes at once.

Source

pub fn scale_x_continuous(self, s: ScaleContinuous) -> Self

Source

pub fn scale_y_continuous(self, s: ScaleContinuous) -> Self

Source

pub fn scale_x_discrete(self, s: ScaleDiscrete) -> Self

Source

pub fn scale_y_discrete(self, s: ScaleDiscrete) -> Self

Source

pub fn scale_color(self, s: impl Scale + 'static) -> Self

Source

pub fn scale_fill(self, s: impl Scale + 'static) -> Self

Source

pub fn scale_color_manual(self, values: Vec<(&str, RGBAColor)>) -> Self

Source

pub fn scale_fill_manual(self, values: Vec<(&str, RGBAColor)>) -> Self

Source

pub fn scale_colour_identity(self) -> Self

The colour/color column already holds #RRGGBB/#RGB hex strings, used as-is — no legend (R’s scale_colour_identity).

Source

pub fn scale_color_identity(self) -> Self

American-spelling alias for scale_colour_identity.

Source

pub fn scale_fill_identity(self) -> Self

The fill column already holds #RRGGBB/#RGB hex strings, used as-is — no legend (R’s scale_fill_identity).

Source

pub fn scale_color_viridis(self) -> Self

Source

pub fn scale_color_brewer(self, name: PaletteName) -> Self

Source

pub fn scale_color_gradient(self, low: RGBAColor, high: RGBAColor) -> Self

Source

pub fn scale_fill_gradient(self, low: RGBAColor, high: RGBAColor) -> Self

Source

pub fn scale_color_gradient2( self, low: RGBAColor, mid: RGBAColor, high: RGBAColor, ) -> Self

Source

pub fn scale_fill_gradient2( self, low: RGBAColor, mid: RGBAColor, high: RGBAColor, ) -> Self

Source

pub fn scale_fill_viridis(self) -> Self

Source

pub fn scale_color_viridis_c(self) -> Self

Continuous viridis color scale (for numeric data).

Source

pub fn scale_fill_viridis_c(self) -> Self

Continuous viridis fill scale (for numeric data).

Source

pub fn scale_color_gradientn(self, stops: Vec<(f64, RGBAColor)>) -> Self

N-stop continuous color gradient.

Source

pub fn scale_fill_gradientn(self, stops: Vec<(f64, RGBAColor)>) -> Self

N-stop continuous fill gradient.

Source

pub fn scale_color_steps( self, low: RGBAColor, high: RGBAColor, n_bins: usize, ) -> Self

Binned (stepped) two-colour continuous colour scale — buckets the mapped variable into n_bins bins, each a discrete colour, with a stepped legend.

Source

pub fn scale_color_stepsn(self, stops: Vec<RGBAColor>, n_bins: usize) -> Self

Binned N-stop continuous colour scale.

Source

pub fn scale_color_fermenter(self, name: PaletteName, n_bins: usize) -> Self

Binned ColorBrewer colour scale (R’s scale_color_fermenter).

Source

pub fn scale_fill_steps( self, low: RGBAColor, high: RGBAColor, n_bins: usize, ) -> Self

Binned (stepped) two-colour continuous fill scale.

Source

pub fn scale_fill_binned( self, breaks: Vec<f64>, low: RGBAColor, high: RGBAColor, ) -> Self

Binned fill scale with explicit class breaks (n + 1 increasing edges, n colours interpolated low→high) — R’s scale_fill_steps(breaks = ...), backing a ::CLASSES choropleth (sipemu/ggplot-rs#180). The legend shows each class’s trained count ("10–50 (12)") and, when any value is Value::Na, a “no data” key in na_color (default grey50) — see ScaleFillBinned for the .na_color(..)/.na_label(..) builders. The break maths itself (quantile/Jenks/equal-width/custom edges) is the caller’s job; this only bins against the edges it’s given.

Source

pub fn scale_fill_binned_with( self, breaks: Vec<f64>, colors: Vec<RGBAColor>, ) -> Self

Like scale_fill_binned, with an explicit colour per bin (colors.len() should be breaks.len() - 1) instead of a two-colour interpolation.

Source

pub fn scale_fill_fermenter(self, name: PaletteName, n_bins: usize) -> Self

Binned ColorBrewer fill scale.

Source

pub fn scale_fill_discrete_sorted(self) -> Self

Default discrete fill palette with levels in sorted order, so a level keeps its colour across charts regardless of data order. For a custom palette: scale_fill(ScaleColorDiscrete::new(Aesthetic::Fill) .with_palette(p).sorted()).

Source

pub fn scale_color_discrete_sorted(self) -> Self

Default discrete colour palette with levels in sorted order (see scale_fill_discrete_sorted).

Source

pub fn scale_fill_brewer(self, name: PaletteName) -> Self

Source

pub fn scale_linetype_manual(self, values: Vec<(&str, Linetype)>) -> Self

Source

pub fn scale_shape_manual(self, values: Vec<(&str, PointShape)>) -> Self

Source

pub fn scale_color_grey(self) -> Self

Source

pub fn scale_fill_grey(self) -> Self

Source

pub fn scale_color_grey_with(self, s: ScaleColorGrey) -> Self

Source

pub fn scale_fill_grey_with(self, s: ScaleColorGrey) -> Self

Source

pub fn scale_x_reverse(self) -> Self

Source

pub fn scale_y_reverse(self) -> Self

Source

pub fn scale_x_datetime(self, s: ScaleDateTime) -> Self

Source

pub fn scale_y_datetime(self, s: ScaleDateTime) -> Self

Source

pub fn scale_size(self, s: ScaleSizeContinuous) -> Self

Source

pub fn scale_size_area(self, max_size: f64) -> Self

scale_size_area(max_size) (ggplot2, B3-6): size scale where area, not radius, is proportional to the value, and 0 maps to 0. See ScaleSizeContinuous::area.

Source

pub fn scale_alpha(self, s: ScaleAlphaContinuous) -> Self

Source

pub fn scale_linewidth(self, s: ScaleLinewidthContinuous) -> Self

Continuous linewidth scale for the linewidth aesthetic (segment, curve, path, line) — see ScaleLinewidthContinuous.

Source

pub fn xlim(self, min: f64, max: f64) -> Self

Source

pub fn ylim(self, min: f64, max: f64) -> Self

Source

pub fn scale_x_log10(self) -> Self

Source

pub fn scale_y_log10(self) -> Self

Source

pub fn scale_x_sqrt(self) -> Self

Source

pub fn scale_y_sqrt(self) -> Self

Source

pub fn scale_x_log2(self) -> Self

Source

pub fn scale_y_log2(self) -> Self

Source

pub fn scale_x_ln(self) -> Self

Source

pub fn scale_y_ln(self) -> Self

Source

pub fn scale_x_logit(self) -> Self

Logit-transformed x axis (for proportions in (0, 1)).

Source

pub fn scale_y_logit(self) -> Self

Source

pub fn scale_x_probit(self) -> Self

Probit-transformed x axis (inverse normal CDF, for proportions in (0, 1)).

Source

pub fn scale_y_probit(self) -> Self

Source

pub fn scale_x_pseudo_log(self) -> Self

Sign-preserving pseudo-log x axis (handles zero and negative values).

Source

pub fn scale_y_pseudo_log(self) -> Self

Source

pub fn scale_x_reciprocal(self) -> Self

Reciprocal (1/x) x axis.

Source

pub fn scale_y_reciprocal(self) -> Self

Source

pub fn scale_x_exp(self) -> Self

Exponential x axis (labels spaced logarithmically).

Source

pub fn scale_y_exp(self) -> Self

Source

pub fn scale_x_boxcox(self, lambda: f64) -> Self

Box–Cox x axis with the given lambda (x > 0).

Source

pub fn scale_y_boxcox(self, lambda: f64) -> Self

Source

pub fn facet_wrap(self, var: &str, ncol: Option<usize>) -> Self

Source

pub fn facet_wrap_free( self, var: &str, ncol: Option<usize>, scales: FacetScales, ) -> Self

Source

pub fn facet_wrap_labeller( self, var: &str, ncol: Option<usize>, labeller: FacetLabeller, ) -> Self

Source

pub fn facet_levels<S: AsRef<str>>(self, levels: &[S]) -> Self

Fix a facet_wrap’s panel order and keep empty panels (ggplot2’s factor levels with drop = FALSE, #329): one panel per entry of levels, in that order, whether or not any layer has rows for it; rows whose facet value isn’t listed are dropped. A value matches a level by its displayed form (1 for the integer 1). Call after facet_wrap*; no effect on other facets.

Source

pub fn facet_grid(self, row: Option<&str>, col: Option<&str>) -> Self

Source

pub fn facet_grid_free( self, row: Option<&str>, col: Option<&str>, scales: FacetScales, ) -> Self

Source

pub fn facet_grid_multi( self, row: Option<&str>, cols: &[&str], scales: FacetScales, space: FacetSpace, ) -> Self

facet_grid over multiple column variables (R’s rows ~ b + c): the columns become the combination of the given variables’ values. Also accepts free scales + proportional space for full parity.

Source

pub fn facet_grid_space( self, row: Option<&str>, col: Option<&str>, scales: FacetScales, space: FacetSpace, ) -> Self

facet_grid with proportional panel sizing (R’s space =): panels are sized to their data range. Typically paired with free scales.

Source

pub fn facet_grid_labeller( self, row: Option<&str>, col: Option<&str>, labeller: FacetLabeller, ) -> Self

Source

pub fn coord_flip(self) -> Self

Source

pub fn coord_fixed(self, ratio: f64) -> Self

Source

pub fn svg_root_data(self, on: bool) -> Self

Whether the rendered root <svg> carries data-plot/data-domain/ data-xdomain/… (see root_data_attrs). Default true. A consumer that overlays a rendered fragment (render_svg_native_at) on its own basemap — which already has its own root attributes and window — turns this off so the fragment adds none of its own.

Source

pub fn svg_attr(self, name: impl Into<String>, value: impl Into<String>) -> Self

Add one extra attribute to the root <svg> element — a host identifier, an ARIA label, a CSS hook, and so on. Allowed names: data-*, aria-*, role, id, class, lang; anything else, or a name ggplot-rs already writes to the root (data-plot, data-domain, …, or data-warnings when svg_warnings_attr is also on), is ignored with a build warning instead of being silently dropped or duplicated. Values are escaped on output. PlotGrid has the same API (PlotGrid::svg_attr).

Source

pub fn svg_attrs( self, attrs: impl IntoIterator<Item = (String, String)>, ) -> Self

svg_attr for several attributes at once.

Source

pub fn svg_warnings_attr(self, on: bool) -> Self

Emit a data-warnings attribute on the root <svg> — a JSON array of the build warnings (rows dropped for non-finite positions, an svg_attr name rejected, …), [] when there are none. Default off, and omitted entirely when off (byte-identical to not calling this).

Source

pub fn svg_formatted_values(self, on: bool) -> Self

Emit data-fvalue/data-fx on marks: the value aesthetic’s raw data value (y for most geoms, fill for hex/tile) and the x value, each formatted through its scale (currency/locale numbers, ISO or locale dates — Scale::format_value) rather than the plain display string data-value/data-x already carry. data-fx is omitted when it would just duplicate data-x. Default off, and omitted entirely when off (byte-identical to not calling this).

Source

pub fn svg_title(self, title: impl Into<String>) -> Self

Give the rendered root <svg> an accessible name: a <title> written (escaped) as its first child, plus role="img" and aria-labelledby pointing at that <title>’s id — the SVG accessibility practice of naming an image via role="img" + aria-labelledby/-describedby rather than a bare <title>, which some screen readers treat as a tooltip instead of a name. Pairs with svg_desc for a longer description; either may be set alone. Default off (None), so output stays byte-identical when this is never called.

Source

pub fn svg_desc(self, desc: impl Into<String>) -> Self

Give the rendered root <svg> an accessible description: a <desc> written (escaped) as a first child (after <title>, if svg_title is also set), plus role="img" and aria-describedby pointing at that <desc>’s id — e.g. a data summary like “4 regions; highest Bavaria (5.2); 1 without data”. Default off (None), so output stays byte-identical when this is never called.

Source

pub fn coord_trans( self, x: Option<ScaleTransform>, y: Option<ScaleTransform>, ) -> Self

Transform the coordinate space at draw time (R’s coord_trans) — stats are computed on raw data but drawn on non-linear axes. Pass a per-axis ScaleTransform (e.g. Some(ScaleTransform::Log10)), None to leave an axis linear.

Source

pub fn coord_trans_y(self, y: ScaleTransform) -> Self

coord_trans on the y-axis only.

Source

pub fn coord_trans_x(self, x: ScaleTransform) -> Self

coord_trans on the x-axis only.

Source

pub fn coord_cartesian_zoom( self, xlim: Option<(f64, f64)>, ylim: Option<(f64, f64)>, ) -> Self

Zoom into a region without filtering data (unlike xlim/ylim which filter).

Source

pub fn coord_polar(self) -> Self

Source

pub fn coord_radar(self) -> Self

Radar / spider chart coordinates: discrete x → spokes, y → distance from the centre, straight segments, ring/spoke guides. Pair with geom_polygon (closed series) and geom_point.

Source

pub fn coord_radar_with(self, coord: CoordRadar) -> Self

Source

pub fn coord_polar_with(self, coord: CoordPolar) -> Self

Source

pub fn theme(self, theme: Theme) -> Self

Replace the theme. A primary_color set earlier is kept unless the new theme sets its own, so preset/primary_color call order doesn’t matter.

Source

pub fn axis_text_x_angle(self, degrees: f64) -> Self

Rotate the x-axis tick labels by degrees (R’s guides(x = guide_axis(angle = ...)) / axis.text.x = element_text(angle)). Useful for long category labels. Call after any theme_*() preset.

Source

pub fn axis_text_y_angle(self, degrees: f64) -> Self

Rotate the y-axis tick labels by degrees.

Source

pub fn axis_text_x_dodge(self, n: usize) -> Self

Stagger x-axis tick labels across n rows to avoid overlap (R’s guides(x = guide_axis(n.dodge = n))). 1 = no dodging.

Source

pub fn aspect_ratio(self, ratio: f64) -> Self

Fix the panel’s height:width ratio (R’s aspect.ratio). Call after any theme_*() preset.

Source

pub fn panel_ontop(self) -> Self

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

Source

pub fn axis_minor_ticks(self) -> Self

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

Source

pub fn axis_text_x_fit(self, fit: AxisLabelFit) -> Self

How an outer x-axis label that would cross the SVG edge is handled (B3-1, D6): AxisLabelFit::Reserve (default), Shift, or Clip (the 0.21 behaviour). Use Shift for panels that must stay pixel-aligned with other elements (e.g. a host’s own aligned strip).

Source

pub fn axis_text_x_check_overlap(self, on: bool) -> Self

Thin crowded x-axis labels in ggplot2’s check.overlap priority order (B3-1, D5). Off by default.

Source

pub fn title_position(self, pos: TitlePosition) -> Self

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

Source

pub fn tag_position(self, pos: TagPosition) -> Self

Corner for the tag() label (R’s plot.tag.position).

Source

pub fn legend_direction(self, dir: LegendDirection) -> Self

Force the legend key layout direction (R’s legend.direction).

Source

pub fn legend_position_inside(self, x: f64, y: f64) -> Self

Set the brand/primary color used as the default for single-series geoms that have no color/fill aesthetic mapped. Composes with any theme — one render process can serve different tenants’ brands at render time. Place the legend inside the panel at panel-relative coordinates (0..1, 0..1) — (0,0) bottom-left, (1,1) top-right (R’s legend.position = c(x, y)).

Source

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

Set the legend position (R’s legend.position, e.g. Top/Bottom).

Source

pub fn legend_bottom_when_narrow(self, share: f64) -> Self

Move a Right legend to Bottom (drawn horizontally) when it would take more than share (0..1) of the panel’s width — the width the panel has with no legend at all (#287). The band is roughly fixed in size, so on a narrow render it can take most of the panel; a render wide enough keeps Right, unchanged. Off by default; no effect on any other position.

Source

pub fn legend_inside_auto(self) -> Self

Put the legend inside the panel, in an empty corner (#332): after layout, each corner’s real legend box is tested against the drawn marks (polygons, lines, points, labels, corner furniture such as a scale bar), and the first corner it overlaps nothing in wins, in the order bottom-right, bottom-left, top-right, top-left. If every corner is taken the legend goes outside, Top or Right, whichever leaves the data area (e.g. a coord_sf map) larger. The choice is written as the root data-legend-at attribute (inside-top-left, top, …). Single-panel plots only; a faceted plot keeps its legend position. See legend_inside_auto_with.

Source

pub fn legend_inside_auto_with( self, corners: &[LegendCorner], fallback: Option<LegendPosition>, ) -> Self

legend_inside_auto with the candidate corners (in preference order) and an outside fallback (Top/Right/Bottom/Left; None = the larger of Top and Right).

Source

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

Source

pub fn theme_minimal(self) -> Self

Source

pub fn theme_bw(self) -> Self

Source

pub fn theme_gray(self) -> Self

Source

pub fn theme_classic(self) -> Self

Source

pub fn theme_pubr(self) -> Self

Apply the publication-ready theme_pubr() (ggpubr style).

Source

pub fn theme_linedraw(self) -> Self

Source

pub fn theme_light(self) -> Self

Source

pub fn theme_dark(self) -> Self

Source

pub fn theme_void(self) -> Self

Source

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

Apply incremental theme modifications on top of the current theme. Like R’s + theme(axis.text.x = element_text(...)).

Source

pub fn guides(self, guide: GuideLegend) -> Self

Configure legend guide (title, ncol, reverse).

Source

pub fn labs(self, labels: Labels) -> Self

Source

pub fn title(self, title: &str) -> Self

Source

pub fn tag(self, tag: &str) -> Self

Corner tag label (R’s labs(tag = ...)), drawn at the top-left — handy for labelling figure panels (“A”, “B”, …).

Source

pub fn subtitle(self, subtitle: &str) -> Self

Source

pub fn xlab(self, label: &str) -> Self

Source

pub fn ylab(self, label: &str) -> Self

Source

pub fn caption(self, caption: &str) -> Self

Source

pub fn annotate(self, annotation: Annotation) -> Self

Add an annotation to the plot.

Source

pub fn annotate_text(self, label: &str, x: f64, y: f64) -> Self

Add a text annotation at data coordinates.

Source

pub fn annotate_rect(self, xmin: f64, xmax: f64, ymin: f64, ymax: f64) -> Self

Add a rectangle annotation at data coordinates.

Source

pub fn annotate_segment(self, x: f64, y: f64, xend: f64, yend: f64) -> Self

Add a segment annotation between data coordinates.

Source

pub fn locale(self, locale: Locale) -> Self

Default Locale for the plot’s axis and legend labels: every continuous position / colour / size / alpha scale labels its default breaks with the locale’s decimal and thousands marks (1.000, 2,5 in de-DE), and date/datetime scales use its month names and date formats (Okt. 2026, 15. Okt. 2026). A scale’s own with_locale and custom label_* formatters take precedence. Without this call labels are unchanged (. decimal mark, no grouping, ISO dates).

use ggplot_rs::prelude::*;
let svg = GGPlot::new(vec![
        ("x".to_string(), vec![Value::Float(0.0), Value::Float(3000.0)]),
        ("y".to_string(), vec![Value::Float(0.5), Value::Float(2.5)]),
    ])
    .aes(Aes::new().x("x").y("y"))
    .geom_point()
    .locale(Locale::from_tag("de-DE"))
    .render_svg_native()
    .unwrap();
assert!(svg.contains(">1.000<") && svg.contains(">1,5<"));
Source

pub fn try_build(self) -> Result<BuiltPlot, GGError>

Build the plot without rendering, returning errors on validation failure.

Source

pub fn build(self) -> BuiltPlot

Build the plot without rendering (analogous to R’s ggplot_build()). Returns the fully computed BuiltPlot with layer data ready for inspection. Panics on validation errors — use try_build() for error handling.

Source

pub fn save(self, path: &str) -> Result<(), GGError>

Build and save the plot to a file. Format determined by extension. (Requires the plotters feature, on by default; native only — wasm has no filesystem/plotters backend.)

Source

pub fn save_with_size(self, path: &str, w: u32, h: u32) -> Result<(), GGError>

Build and save with custom dimensions. (Feature plotters; native only.)

Source

pub fn render_svg(self) -> Result<String, GGError>

Render the plot to an in-memory SVG document (default 800x600).

Unlike save, this writes nothing to disk — handy for serving charts from a web/MCP service. Requires the plotters feature (on by default); without it use render_svg_native.

Source

pub fn render_svg_with_size(self, w: u32, h: u32) -> Result<String, GGError>

Render the plot to an in-memory SVG document with custom dimensions. (Feature plotters; native only — on wasm or without plotters use render_svg_native_with_size.)

Source

pub fn render_svg_native(self) -> Result<String, GGError>

Render to SVG through the self-contained SvgBackend — a plotters-free path that drives the same PlotRenderer, proving the DrawBackend abstraction (and needing no glyph rasterization).

Source

pub fn render_svg_native_with_size( self, w: u32, h: u32, ) -> Result<String, GGError>

render_svg_native with an explicit size.

The root <svg> carries data-plot="x y w h" (the panel rect) and the trained position domains (data-domain, data-xdomain, data-ydomain, data-xlevels, data-ylevels — see root_data_attrs). Hoverable marks carry data-x, data-series and data-value.

Source

pub fn render_svg_native_with_warnings( self, w: u32, h: u32, ) -> Result<(String, Vec<String>), GGError>

Like render_svg_native_with_size, but also returns the build warnings (rows dropped for non-finite positions, layers whose stat produced no data, …) — see BuiltPlot::warnings.

Source

pub fn render_svg_native_at( self, x: f64, y: f64, w: u32, h: u32, ) -> Result<String, GGError>

Render a w×h chart as a nested <svg x=.. y=.. width=.. height=.. viewBox="0 0 w h"> fragment for composition into a larger SVG (a dashboard): no xmlns (inherited from the parent), positioned at (x, y) in the parent’s user space. No string surgery needed:

ⓘ
let mut page = String::from(r#"<svg xmlns="http://www.w3.org/2000/svg" width="900" height="400">"#);
page += &plot_a.render_svg_native_at(0.0, 0.0, 450, 400)?;
page += &plot_b.render_svg_native_at(450.0, 0.0, 450, 400)?;
page += "</svg>";
Source

pub fn render_svg_area_with_size( self, w: u32, h: u32, ) -> Result<(String, [f64; 4]), GGError>

Like render_svg_native_with_size, but also returns the panel rect in pixels [x, y, w, h] — enough to overlay a WebGL/canvas layer that draws marks in data coordinates.

Source

pub fn render_png(self) -> Result<Vec<u8>, GGError>

Render the plot to in-memory PNG bytes (default 800x600).

Returns a fully-encoded PNG, ready to write to an HTTP response or embed as a data URI — no temp files involved. Requires the plotters feature (on by default); see also render_png_raster_with_size (feature canvas).

Source

pub fn render_png_with_size(self, w: u32, h: u32) -> Result<Vec<u8>, GGError>

Render the plot to in-memory PNG bytes with custom dimensions. (Feature plotters; native only — PNG needs the plotters bitmap backend.)

Source

pub fn ggsave( self, path: &str, width_inches: f64, height_inches: f64, dpi: f64, ) -> Result<(), GGError>

Save with physical dimensions (inches) and DPI. (Feature plotters; native only.)

Trait Implementations§

Source§

impl BitOr for GGPlot

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: GGPlot) -> PlotGrid

Performs the | operation. Read more
Source§

impl BitOr<GGPlot> for PlotGrid

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: GGPlot) -> PlotGrid

Performs the | operation. Read more
Source§

impl BitOr<PlotGrid> for GGPlot

a | b: place side by side (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: PlotGrid) -> PlotGrid

Performs the | operation. Read more
Source§

impl Div for GGPlot

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: GGPlot) -> PlotGrid

Performs the / operation. Read more
Source§

impl Div<GGPlot> for PlotGrid

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: GGPlot) -> PlotGrid

Performs the / operation. Read more
Source§

impl Div<PlotGrid> for GGPlot

a / b: stack vertically (patchwork).

Source§

type Output = PlotGrid

The resulting type after applying the / operator.
Source§

fn div(self, rhs: PlotGrid) -> PlotGrid

Performs the / operation. Read more
Source§

impl From<GGPlot> for GridCell

Source§

fn from(p: GGPlot) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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, 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