r/interpreter/graphics/
plot_data.rs1#[derive(Debug, Clone)]
12pub enum PlotItem {
13 Line {
15 x: Vec<f64>,
16 y: Vec<f64>,
17 color: [u8; 4],
18 width: f32,
19 label: Option<String>,
20 },
21 Points {
23 x: Vec<f64>,
24 y: Vec<f64>,
25 color: [u8; 4],
26 size: f32,
27 shape: u8,
28 label: Option<String>,
29 },
30 Bars {
32 x: Vec<f64>,
33 heights: Vec<f64>,
34 color: [u8; 4],
35 width: f64,
36 label: Option<String>,
37 },
38 BoxPlot {
40 positions: Vec<f64>,
41 spreads: Vec<BoxSpread>,
42 color: [u8; 4],
43 },
44 HLine { y: f64, color: [u8; 4], width: f32 },
46 VLine { x: f64, color: [u8; 4], width: f32 },
48 Text {
50 x: f64,
51 y: f64,
52 text: String,
53 color: [u8; 4],
54 },
55}
56
57#[derive(Debug, Clone)]
63pub struct BoxSpread {
64 pub lower_whisker: f64,
65 pub q1: f64,
66 pub median: f64,
67 pub q3: f64,
68 pub upper_whisker: f64,
69}
70
71#[derive(Debug, Clone)]
80pub struct PlotState {
81 pub items: Vec<PlotItem>,
82 pub title: Option<String>,
83 pub x_label: Option<String>,
84 pub y_label: Option<String>,
85 pub x_lim: Option<(f64, f64)>,
86 pub y_lim: Option<(f64, f64)>,
87 pub show_legend: bool,
88}
89
90impl PlotState {
91 pub fn new() -> Self {
92 Self {
93 items: Vec::new(),
94 title: None,
95 x_label: None,
96 y_label: None,
97 x_lim: None,
98 y_lim: None,
99 show_legend: false,
100 }
101 }
102}
103
104impl Default for PlotState {
105 fn default() -> Self {
106 Self::new()
107 }
108}
109
110