Skip to content

Waterfall

1
waterfall(X, Y, Z);

example_waterfall_1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;
    auto [X, Y] = meshgrid(iota(-3, .125, 3));
    auto Z = peaks(X, Y);
    waterfall(X, Y, Z);

    show();
    return 0;
}

More examples

example_waterfall_2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;
    auto [X, Y] = meshgrid(iota(-3, .125, 3));
    auto Z = peaks(X, Y);
    auto [FX, FY] = gradient(Z);
    (void) FY;
    waterfall(X, Y, Z, FX);
    colorbar();

    show();
    return 0;
}

example_waterfall_3

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <cmath>
#include <matplot/matplot.h>

int main() {
    using namespace matplot;
    auto [X, Y] = meshgrid(iota(-5, .5, 5));
    auto Z = transform(
        X, Y, [](double x, double y) { return y * sin(x) - x * cos(y); });
    waterfall(X, Y, Z)->edge_color("b");

    show();
    return 0;
}