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 new(data: impl GGData) -> Self

Create a new plot with the given data source.

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

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_vline(self, xintercept: f64) -> Self

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_abline(self, slope: f64, intercept: f64) -> Self

Source

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

Add a slope/intercept reference line with custom styling.

Source

pub fn geom_text(self) -> Self

Source

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

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_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 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 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_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_fermenter(self, name: PaletteName, n_bins: usize) -> Self

Binned ColorBrewer fill scale.

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_alpha(self, s: ScaleAlphaContinuous) -> Self

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_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 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_polar_with(self, coord: CoordPolar) -> Self

Source

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

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

Source

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

Build and save with custom dimensions.

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.

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.

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.

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.

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.

Source

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

Save with physical dimensions (inches) and DPI.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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