Skip to main content

ggplot_rs/coord/
flip.rs

1use crate::render::Rect;
2
3use super::Coord;
4
5/// Flipped coordinate system — swaps X and Y axes.
6pub struct CoordFlip;
7
8impl Coord for CoordFlip {
9    fn transform(&self, point: (f64, f64), plot_area: &Rect) -> (f64, f64) {
10        let (nx, ny) = point;
11        // Swap: x maps to vertical, y maps to horizontal
12        let px = plot_area.x + ny * plot_area.width;
13        let py = plot_area.y + (1.0 - nx) * plot_area.height;
14        (px, py)
15    }
16
17    fn is_flipped(&self) -> bool {
18        true
19    }
20}