# gnuplot-wrapper
Gnuplot - to get started with gnuplot.
GnuplotLiveProcess - for working with gnuplot in interactive mode.
GnuplorScriptProcess - for working with gnuplot in script launch mode.
Script - script for gnuplot.
```rust
Gnuplot::execute(script).wait().unwrap();
```
# How to use
## Start gnuplot
First of all we need to start gnuplot. There are three ways to do this.
```rust
Gnuplot::new(); // equals to Gnuplot::new_with_path_str("gnuplot")
Gnuplot::new_with_path_str("gnuplot");
Gnuplot::new_with_path(&String::from("gnuplot"));
```
## Select mode
Then you need to decide in which mode you want to work with gnuplot and create an instance of gnuplot.
Scripting mode:
```rust
let script: Script = ...;
let mut gnuplot_process: GnuplorScriptProcess = gnuplot.execute_script(script);
```
Live mode:
```rust
let mut gnuplot_process: GnuplotLiveProcess = gnuplot.run_live();
```
## Wait for gnuplot to complete
Wait for gnuplot to complete.
```rust
gnuplot_process.wait();
```
# How to create a script
```rust
let mut script = Script::new();
script.add_raw_command("set term qt 0");
script.add_raw_command("plot sin(x)");
script.add_raw_command("set term qt 1");
script.add_raw_command("plot cos(x)");
script.save("/tmp/wk.plt");
```
# How to send a command to a live gnuplot
```rust
gnuplot_process.write("set term qt 1");
```
# How to wait for gnuplot to complete in live mode?
```rust
gnuplot_process.write("pause mouse close");
gnuplot_process.wait();
```