Skip to content

Filled Contour

1
contourf(X, Y, Z);

example_contourf_1

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    contourf(X, Y, Z);

    show();
    return 0;
}

More examples

example_contourf_2

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

int main() {
    using namespace matplot;

    std::vector<double> x = linspace(-2 * pi, 2 * pi);
    std::vector<double> y = linspace(0, 4 * pi);
    auto [X, Y] = meshgrid(x, y);
    vector_2d Z =
        transform(X, Y, [](double x, double y) { return sin(x) + cos(y); });
    contourf(X, Y, Z, 10);

    show();
    return 0;
}

example_contourf_3

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    contourf(X, Y, Z, {2, 3})->contour_text(true);

    show();
    return 0;
}

example_contourf_4

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    contourf(X, Y, Z, {2});

    show();
    return 0;
}

example_contourf_5

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    contourf(X, Y, Z, "--");

    show();
    return 0;
}

example_contourf_6

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    contourf(X, Y, Z)->line_width(3);

    show();
    return 0;
}