Struct plotpy::Surface[][src]

pub struct Surface { /* fields omitted */ }
Expand description

Generates a 3D a surface (or wireframe, or both)

Example

// import
use plotpy::{Surface, 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 and draw surface + wireframe
let mut surface = Surface::new();
surface.set_colormap_name("seismic")
    .set_with_colorbar(true)
    .set_with_wireframe(true)
    .set_line_width(0.3);

// draw surface + wireframe
surface.draw(&x, &y, &z);

// add surface to plot
let mut plot = Plot::new();
plot.add(&surface)
    .set_title("horse saddle equation") // must be after add surface
    .set_camera(20.0, 35.0); // must be after add surface

// save figure
let path = Path::new(OUT_DIR).join("doc_surface.svg");
plot.save(&path)?;

doc_surface.svg

Implementations

Creates a new Surface object

Draws a surface, or wireframe, or both

Input

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

Flags

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

  • surface – draws surface
  • wireframe – draws wireframe

Notes

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

Sets the row stride

Sets the column stride

Sets option to generate surface

Sets option to generate wireframe

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

Options:

Sets option to draw a colorbar

Sets the colorbar label

Sets the number format for the labels in the colorbar (cb)

Sets the color of wireframe lines

Sets the style of wireframe line

Options:

  • -”, “:”, “--”, “-.

Sets the width of wireframe line

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.