Struct plotpy::Surface [−][src]
pub struct Surface {
pub row_stride: i32,
pub col_stride: i32,
pub surface: bool,
pub wireframe: bool,
pub colormap_index: i32,
pub colormap_name: String,
pub colorbar: bool,
pub colorbar_label: String,
pub colorbar_number_format: String,
pub line_color: String,
pub line_style: String,
pub line_width: f64,
// some fields omitted
}
Expand description
Generates a 3D a surface (or wireframe, or both)
Example
// import
use plotpy::*;
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 mut x = vec![vec![0.0; n]; n];
let mut y = vec![vec![0.0; n]; n];
let mut z = vec![vec![0.0; n]; n];
let (min, max) = (-2.0, 2.0);
let d = (max - min) / ((n - 1) as f64);
for i in 0..n {
let v = min + (i as f64) * d;
for j in 0..n {
let u = min + (j as f64) * d;
x[i][j] = u;
y[i][j] = v;
z[i][j] = u * u - v * v;
}
}
// configure and draw surface + wireframe
let mut surface = Surface::new();
surface.colormap_name = "seismic".to_string();
surface.colorbar = true;
surface.wireframe = true;
surface.line_width = 0.3;
surface.draw(&x, &y, &z);
// add surface to plot
let mut plot = Plot::new();
plot.add(&surface);
plot.camera(20.0, 35.0); // must be after add surface
// save figure
let path = Path::new(OUT_DIR).join("doc_surface.svg");
plot.title("horse saddle equation");
plot.save(&path)?;
Fields
row_stride: i32
Row stride
col_stride: i32
Column stride
surface: bool
Generates a surface
wireframe: bool
Generates a wireframe
colormap_index: i32
Colormap index
- 0 – bwr
- 1 – RdBu
- 2 – hsv
- 3 – jet
- 4 – terrain
- 5 – pink
- 6 – Greys
>
6 – starts over from 0
colormap_name: String
Colormap name as defined in https://matplotlib.org/stable/tutorials/colors/colormaps.html
Will use colormap_index
instead if colormap_name
is empty.
colorbar: bool
Draw a colorbar
colorbar_label: String
Colorbar label
colorbar_number_format: String
Number format for the labels in lines contour (e.g. “%.2f”)
line_color: String
Color of wireframe lines
line_style: String
Style of wireframe line
Options: “-
”, “:
”, “--
”, “-.
”
line_width: f64
Width of wireframe line