quick_plot_2d_with_labels

Function quick_plot_2d_with_labels 

Source
pub fn quick_plot_2d_with_labels(
    x: impl Into<Vec<f64>>,
    y: impl Into<Vec<f64>>,
    x_label: impl Into<String>,
    y_label: impl Into<String>,
    title: impl Into<String>,
) -> Figure
Expand description

Quickly create a 2D plot with axis labels and a title.

§Arguments

  • x - x-axis data.
  • y - y-axis data.

§x_label - x-axis label.

  • y_label - y-axis label.
  • title - Title.

§Returns

Figure.

§Example

use plotting::{quick_plot_2d_with_labels, Figure};

// Plot y = x^2.
let fig: Figure = quick_plot_2d_with_labels(
    [1.0, 2.0, 3.0],
    [1.0, 4.0, 9.0],
    "x",
    "y",
    "y = x^2",
);

§Additional examples

Additional examples can be found at https://tamaskis.github.io/plotting/plot_2d/quick_2d_plot_with_labels.html.

Examples found in repository?
examples/quick_plot_2d_with_labels.rs (line 7)
4fn main() {
5    // Create the figure.
6    let fig: Figure =
7        quick_plot_2d_with_labels([1.0, 2.0, 3.0], [1.0, 4.0, 9.0], "x", "y", "y = x^2");
8
9    // Save the figure so it can be displayed right below this example.
10    fig.save_inline_html(Path::new("book/src/figures/quick_plot_2d_with_labels.html"));
11
12    // Alternatively, you can show the figure in a web browser.
13    // fig.show();
14}