Customizable plotting function. Takes any type that implements [`Plotable`], namely `Vec `, `Vec<(f64, f64)>`, `Vec `, ...
(&mut self, v: T, options: Vec<Opt>)
| 633 | /// Customizable plotting function. Takes any type that implements [`Plotable`], namely |
| 634 | /// `Vec<Vec2>`, `Vec<(f64, f64)>`, `Vec<f32>`, ... |
| 635 | pub fn plotopt<T: Plotable>(&mut self, v: T, options: Vec<Opt>) { |
| 636 | // |
| 637 | let data_in_plot_format: PlotFormat = v.into_plot_format(); |
| 638 | |
| 639 | if !options.contains(&Opt::LineStyle(LineStyle::None)) { |
| 640 | let mut data = SegmentData { |
| 641 | data: data_in_plot_format.data.clone(), |
| 642 | ..Default::default() |
| 643 | }; |
| 644 | |
| 645 | for option in options.iter() { |
| 646 | match option { |
| 647 | Opt::Color(col) => { |
| 648 | data.color = *col; |
| 649 | } |
| 650 | |
| 651 | Opt::Size(si) => { |
| 652 | data.size = *si; |
| 653 | } |
| 654 | Opt::LineStyle(style) => { |
| 655 | data.line_style = style.clone(); |
| 656 | } |
| 657 | |
| 658 | Opt::Mech(mech) => { |
| 659 | data.mech = *mech; |
| 660 | } |
| 661 | |
| 662 | _ => {} |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | self.data.segment_groups.push(data); |
| 667 | } |
| 668 | |
| 669 | // Decide whether to draw markers using the options. |
| 670 | // If any of MarkerStyle or MarkerSize is specified, draw markers |
| 671 | let draw_markers = options |
| 672 | .iter() |
| 673 | .map(|opt| { |
| 674 | if let &Opt::MarkerStyle(_) = opt { |
| 675 | true |
| 676 | } else if let &Opt::MarkerSize(_) = opt { |
| 677 | true |
| 678 | } else { |
| 679 | false |
| 680 | } |
| 681 | }) |
| 682 | .any(|x| x); |
| 683 | |
| 684 | if draw_markers { |
| 685 | let mut data = MarkerData { |
| 686 | data: data_in_plot_format.data.clone(), |
| 687 | ..Default::default() |
| 688 | }; |
| 689 | |
| 690 | for option in options.iter() { |
| 691 | match option { |
| 692 | Opt::MarkerColor(col) => { |
no test coverage detected