Trait preexplorer::traits::Plotable
source · pub trait Plotable: Configurable + Saveable {
// Required method
fn plot_script(&self) -> String;
// Provided methods
fn plot_later<S: Display>(
&mut self,
id: S
) -> Result<&mut Self, PreexplorerError> { ... }
fn plot<S: Display>(&mut self, id: S) -> Result<&mut Self, PreexplorerError> { ... }
fn plot_with_script<S: Display, T: Display>(
&mut self,
id: S,
script: T
) -> Result<&mut Self, PreexplorerError> { ... }
fn write_plot_script<S: Display>(
&self,
gnuplot_script: S
) -> Result<&Self, PreexplorerError> { ... }
fn opening_plot_script(&self) -> String { ... }
fn ending_plot_script(&self) -> String { ... }
}
Required Methods§
sourcefn plot_script(&self) -> String
fn plot_script(&self) -> String
Construct a suitable plot script for the struct.
Provided Methods§
sourcefn plot_later<S: Display>(
&mut self,
id: S
) -> Result<&mut Self, PreexplorerError>
fn plot_later<S: Display>( &mut self, id: S ) -> Result<&mut Self, PreexplorerError>
Do everything except running the command of plotting. In other words:
- Assign id.
- Save the data.
- Save the plot script.
§Remarks
Specially useful when used in Data
struct. So one can write the
particular plot script later.
§Examples
Save data and plot script for posterior analysis.
let data = array![
[1, 2, 3, 4, 5],
[2, 5, 6, 7, 8],
[3, 11, 12, 13, 14],
];
let dim = 5;
pre::Data::new(data.iter(), dim)
.plot_later("my_identifier")
.unwrap();
sourcefn plot<S: Display>(&mut self, id: S) -> Result<&mut Self, PreexplorerError>
fn plot<S: Display>(&mut self, id: S) -> Result<&mut Self, PreexplorerError>
Main command. In other words:
- Assign id.
- Save the data.
- Save the plot script.
- Run (asynchronous) the plot script.
§Examples
Quickest plot.
(0..10).preexplore()
.plot("my_identifier")
.unwrap();
sourcefn plot_with_script<S: Display, T: Display>(
&mut self,
id: S,
script: T
) -> Result<&mut Self, PreexplorerError>
fn plot_with_script<S: Display, T: Display>( &mut self, id: S, script: T ) -> Result<&mut Self, PreexplorerError>
Plot with a custom script. In other words:
- Assign id.
- Save the data.
- Save the custom plot script.
- Run (asynchronous) the plot script.
§Remarks
This is useful when you found a particular gnuplot script you want to plot your data with and want to do it directly from Rust. Then, you must hard-code your script in Rust (copy-paste from internet, most of the times).
Note that you will have to write the full path to the data in the gnuplot format, see the example for more.
§Examples
Quickest plot.
let mut seq = (0..10).preexplore();
seq.plot_with_script("my_identifier", "
plot \"target/preexplorer/data/my_identifier.txt\" with linespoints linecolor 3
pause 3
").unwrap();
sourcefn write_plot_script<S: Display>(
&self,
gnuplot_script: S
) -> Result<&Self, PreexplorerError>
fn write_plot_script<S: Display>( &self, gnuplot_script: S ) -> Result<&Self, PreexplorerError>
Write plot script given by plot_script
in the machine for posterior running.
§Remarks
The method plot_later
might be more useful.
sourcefn opening_plot_script(&self) -> String
fn opening_plot_script(&self) -> String
Helper method for implementing Plotable
.
sourcefn ending_plot_script(&self) -> String
fn ending_plot_script(&self) -> String
Helper method for implementing Plotable
.