FormatBuilder

Struct FormatBuilder 

Source
pub struct FormatBuilder { /* private fields */ }
Expand description

Builder for Format.

Implementations§

Source§

impl FormatBuilder

Source

pub fn title<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self

Title.

Examples found in repository?
examples/general_2d_plot.rs (line 19)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 19)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn x_label<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self

x-axis label.

Examples found in repository?
examples/general_2d_plot.rs (line 20)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 20)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn y_label<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self

y-axis label.

Examples found in repository?
examples/general_2d_plot.rs (line 21)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 21)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn z_label<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self

z-axis label.

Examples found in repository?
examples/general_3d_plot.rs (line 22)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn width(&mut self, value: usize) -> &mut Self

Width (in pixels).

Examples found in repository?
examples/general_2d_plot.rs (line 22)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 23)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn height(&mut self, value: usize) -> &mut Self

Height (in pixels).

Examples found in repository?
examples/general_2d_plot.rs (line 23)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 24)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}
Source

pub fn build(&self) -> Result<Format, FormatBuilderError>

Builds a new Format.

§Errors

If a required field has not been initialized.

Examples found in repository?
examples/general_2d_plot.rs (line 24)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7        .name("y = x")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12        .name("y = x^2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("y vs. x")
20        .x_label("x")
21        .y_label("y")
22        .width(800)
23        .height(600)
24        .build()
25        .unwrap();
26
27    // Create the figure.
28    let fig = Figure::new(vec![trace_1, trace_2], format);
29
30    // Save the figure so it can be displayed right below this example.
31    fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33    // Alternatively, you can show the figure in a web browser.
34    // fig.show();
35}
More examples
Hide additional examples
examples/general_3d_plot.rs (line 25)
4fn main() {
5    // Define the traces.
6    let trace_1 = Trace::new_3d([1.0, 2.0, 5.0], [1.0, 2.0, 3.0], [1.0, 2.0, 4.0])
7        .name("Trace 1")
8        .line_color(Color::named(NamedColor::Red))
9        .line_width(2.0)
10        .line_style(LineStyle::Dash);
11    let trace_2 = Trace::new_3d([1.0, 2.0, 5.0], [3.0, 2.0, 1.0], [1.0, 2.0, 4.0])
12        .name("Trace 2")
13        .line_color(Color::named(NamedColor::Blue))
14        .line_width(2.0)
15        .line_style(LineStyle::Dot);
16
17    // Figure formatting.
18    let format: Format = FormatBuilder::default()
19        .title("z vs. x and y")
20        .x_label("x")
21        .y_label("y")
22        .z_label("z")
23        .width(800)
24        .height(600)
25        .build()
26        .unwrap();
27
28    // Create the figure.
29    let fig = Figure::new(vec![trace_1, trace_2], format);
30
31    // Save the figure so it can be displayed right below this example.
32    fig.save_inline_html(Path::new("book/src/figures/general_3d_plot.html"));
33
34    // Alternatively, you can show the figure in a web browser.
35    // fig.show();
36}

Trait Implementations§

Source§

impl Clone for FormatBuilder

Source§

fn clone(&self) -> FormatBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for FormatBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.