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)


// 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);, 35.0); // must be after add surface

// save figure
let path = Path::new(OUT_DIR).join("doc_surface.svg");
plot.title("horse saddle equation");;



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

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


Creates a new Surface object

Draws a surface, or wireframe, or both


  • x – matrix with x values
  • y – matrix with y values
  • z – matrix with z values


The following flags control what features are not to be drawn:

  • surface – draws surface
  • wireframe – draws wireframe


  • The type T of the input matrices must be a number.

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.