pub fn generate2d(
xmin: f64,
xmax: f64,
ymin: f64,
ymax: f64,
nx: usize,
ny: usize,
) -> (Vec<Vec<f64>>, Vec<Vec<f64>>)Expand description
Generates 2d meshgrid points
This is analogous to numpy.meshgrid
with indexing='ij'. Produces two (ny × nx) matrices where each row has the same y
value and each column has the same x value.
§Input
xmin,xmax– range along xymin,ymax– range along ynx– number of points along x (must be>= 2)ny– number of points along y (must be>= 2)
§Output
x,y– (nybynx) 2D arrays such thatx[i][j] = xmin + j·dxandy[i][j] = ymin + i·dy
§Example
use plotpy::generate2d;
let (x, y) = generate2d(-1.0, 1.0, -3.0, 3.0, 2, 3);
assert_eq!(x, vec![vec![-1.0, 1.0], vec![-1.0, 1.0], vec![-1.0, 1.0]]);
assert_eq!(y, vec![vec![-3.0, -3.0], vec![0.0, 0.0], vec![3.0, 3.0]]);See also: generate3d