Struct plotpy::Contour [−][src]
pub struct Contour { /* fields omitted */ }
Expand description
Generates a contour plot
Example
// import
use plotpy::{Contour, Plot};
use russell_lab::generate3d;
use std::path::Path;
// directory to save figures
const OUT_DIR: &str = "/tmp/plotpy/doc_tests";
// generate (x,y,z) matrices
let n = 21;
let (x, y, z) = generate3d(-2.0, 2.0, -2.0, 2.0, n, n, |x, y| x * x - y * y);
// configure contour
let mut contour = Contour::new();
contour
.set_colorbar_label("temperature")
.set_colormap_name("terrain")
.set_selected_line_color("#f1eb67")
.set_selected_line_width(12.0)
.set_selected_level(0.0, true);
// draw contour
contour.draw(&x, &y, &z);
// add contour to plot
let mut plot = Plot::new();
plot.add(&contour)
.set_labels("x", "y");
// save figure
let path = Path::new(OUT_DIR).join("doc_contour.svg");
plot.save(&path)?;
Implementations
Draws a fancy contour: filled contour with a line contour and a colorbar
Input
x
– matrix with x valuesy
– matrix with y valuesz
– matrix with z values
Flags
The following flags control what features are not to be drawn:
no_lines
– skip drawing a lines contour on top of the filled contourno_labels
– skip adding labels to the lines contour (if enabled)no_colorbar
– skip drawing a colorbarwith_selected
– draw a line contour with a selected level (e.g., 0.0) on top of everything
Notes
- The type
U
of the input matrices must be a number.
Sets the colors to be used instead of a pre-defined colormap
Will use colormap_index
instead if its empty.
Sets pre-defined levels, otherwise automatically calculate levels
Sets the colormap index
Options:
- 0 – bwr
- 1 – RdBu
- 2 – hsv
- 3 – jet
- 4 – terrain
- 5 – pink
- 6 – Greys
>
6 – starts over from 0
Sets the colormap name
Colormap names:
Will use colormap_index
instead if colormap_name
is empty.
Sets option to skip drawing a lines contour on top of the filled contour
Sets option to skip adding labels to the lines contour (if enabled)
Sets option to skip drawing labels inline with the contour lines (if enabled)
Sets option to skip drawing a colorbar
Sets the colorbar label
Sets the number format for the labels in the colorbar (cb)
Sets the line color for the lines contour (default is black)
Sets the line style for the lines contour
Options:
- “
-
”, “:
”, “--
”, “-.
”
Sets the line width for the lines contour
Sets the font size for labels
Sets option to draw a line contour with a selected level (e.g., 0.0)
Will draw the selected level (e.g., 0.0) on top of everything
Sets the color to mark the selected level
Sets the line style for the selected level
Options:
- “
-
”, “:
”, “--
”, “-.
”
Sets the line width for the selected level