Skip to main content

Coord

Trait Coord 

Source
pub trait Coord: Send + Sync {
Show 14 methods // Required method fn transform(&self, point: (f64, f64), plot_area: &Rect) -> (f64, f64); // Provided methods fn fixed_aspect(&self) -> Option<f64> { ... } fn data_rect(&self, _plot_area: &Rect) -> Option<Rect> { ... } fn gridlines(&self) -> bool { ... } fn is_flipped(&self) -> bool { ... } fn is_polar(&self) -> bool { ... } fn polar_theta_is_x(&self) -> bool { ... } fn zoom_x(&self) -> Option<(f64, f64)> { ... } fn zoom_y(&self) -> Option<(f64, f64)> { ... } fn set_domains(&mut self, _x: Option<AxisSpan>, _y: Option<AxisSpan>) { ... } fn is_radar(&self) -> bool { ... } fn train_scales(&mut self, _scales: &mut ScaleSet) { ... } fn discrete_expand(&self) -> bool { ... } fn supports_axis_reserve(&self) -> bool { ... }
}
Expand description

Trait for coordinate systems.

Required Methods§

Source

fn transform(&self, point: (f64, f64), plot_area: &Rect) -> (f64, f64)

Transform normalized (0..1, 0..1) coordinates to pixel coordinates.

Provided Methods§

Source

fn fixed_aspect(&self) -> Option<f64>

The panel aspect (height / width) this coord letterboxes to, if any. facet_wrap sizes its panels to it (so every map panel is filled instead of letterboxed in an equal, arbitrary cell). Default None.

Source

fn data_rect(&self, _plot_area: &Rect) -> Option<Rect>

The rect inside plot_area the normalized data window maps onto, for a coord that letterboxes (coord_sf); None when it is the whole plot area or not a rectangle. Default None.

Source

fn gridlines(&self) -> bool

Whether to draw grid lines.

Source

fn is_flipped(&self) -> bool

Whether this coordinate system flips X and Y.

Source

fn is_polar(&self) -> bool

Whether this is a non-linear polar system (bars become radial sectors, so geoms that draw rectangles must tessellate their edges into an arc).

Source

fn polar_theta_is_x(&self) -> bool

For a polar system, whether the x aesthetic maps to angle (theta="x"). When false (theta="y", pies), the y aesthetic is the angle, so sector tessellation must sweep the y edge instead of the x edge.

Source

fn zoom_x(&self) -> Option<(f64, f64)>

Zoom limits for x-axis (data coordinates). Clips viewport without filtering data.

Source

fn zoom_y(&self) -> Option<(f64, f64)>

Zoom limits for y-axis (data coordinates). Clips viewport without filtering data.

Source

fn set_domains(&mut self, _x: Option<AxisSpan>, _y: Option<AxisSpan>)

Supply the trained x/y axis spans after scale training. Coordinate systems that warp the axis (e.g. coord_trans) need this to map a normalized position back to a data value. Default is a no-op.

Source

fn is_radar(&self) -> bool

Radar coordinates: straight segments between spokes, closed paths, and ring/spoke guides instead of cartesian axes. Default false.

Source

fn train_scales(&mut self, _scales: &mut ScaleSet)

Inspect / adjust the trained scales once training is complete (e.g. coord_radar anchors the radius at 0 and counts its spokes). Default: no-op.

Source

fn discrete_expand(&self) -> bool

Whether bars on a discrete axis keep the band padding (10 % of the panel split across the ends). coord_polar().expand(false) turns it off so a full-width pie closes at the centre. Default true.

Source

fn supports_axis_reserve(&self) -> bool

Whether Theme::axis_text_x_fit’s Reserve mode may grow the panel margin for this coordinate system (B3-1). transform isn’t a simple linear per-axis map for polar/radar (angle) or sf (letterboxed, non-degree units), so reserving a left/right margin from a label bbox would be meaningless there; those coords still get the draw-time Shift fallback in draw_x_axis. Default true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§