Skip to content

Commit

Permalink
Merge pull request #244 from rmburg/examples-swap-x-y
Browse files Browse the repository at this point in the history
Examples: fix swapped x and y
  • Loading branch information
andrei-ng authored Nov 12, 2024
2 parents 6e06fcc + e2c4834 commit 78fddde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/3d_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ fn surface_plot() {
let n: usize = 100;
let x: Vec<f64> = Array::linspace(-10., 10., n).into_raw_vec_and_offset().0;
let y: Vec<f64> = Array::linspace(-10., 10., n).into_raw_vec_and_offset().0;
let z: Vec<Vec<f64>> = x
let z: Vec<Vec<f64>> = y
.iter()
.map(|i| {
y.iter()
x.iter()
.map(|j| 1.0 / (j * j + 5.0) * j.sin() + 1.0 / (i * i + 5.0) * i.cos())
.collect()
})
Expand Down
12 changes: 6 additions & 6 deletions examples/scientific_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn simple_contour_plot() {
y.push(value);
}

x.iter().take(n).for_each(|x| {
y.iter().take(n).for_each(|y| {
let mut row = Vec::<f64>::new();
y.iter().take(n).for_each(|y| {
x.iter().take(n).for_each(|x| {
let radius_squared = x.powf(2.0) + y.powf(2.0);
let zv = x.sin() * y.cos() * radius_squared.sin() / (radius_squared + 1.0).log10();
row.push(zv);
Expand Down Expand Up @@ -112,11 +112,11 @@ fn basic_heat_map() {
fn customized_heat_map() {
let x = (0..100).map(|x| x as f64).collect::<Vec<f64>>();
let y = (0..100).map(|y| y as f64).collect::<Vec<f64>>();
let z: Vec<Vec<f64>> = x
let z: Vec<Vec<f64>> = y
.iter()
.map(|x| {
y.iter()
.map(|y| (x / 5.0).powf(2.0) + (y / 5.0).powf(2.0))
.map(|y| {
x.iter()
.map(|x| (x / 5.0).powf(2.0) + (y / 5.0).powf(2.0))
.collect::<Vec<f64>>()
})
.collect::<Vec<Vec<f64>>>();
Expand Down

0 comments on commit 78fddde

Please sign in to comment.