Skip to content

Z Limits

1
zlim({zmin,zmax});

example_zlim_1

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    surf(X, Y, Z);
    zlim({-5, 5});

    show();
    return 0;
}

More examples

example_zlim_2

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

int main() {
    using namespace matplot;

    auto [X, Y, Z] = peaks();
    mesh(X, Y, Z);
    zlim({0, inf});

    show();
    return 0;
}

example_zlim_3

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <matplot/matplot.h>
#include <set>
#include <thread>
#include <vector>

int main() {
    using namespace matplot;

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

    tiledlayout(2, 1);

    auto ax1 = nexttile();
    surf(ax1, X, Y, Z);

    auto ax2 = nexttile();
    surf(ax2, X, Y, Z);
    zlim(ax2, {-5, 5});

    show();
    return 0;
}

example_zlim_4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <matplot/matplot.h>
#include <set>
#include <thread>
#include <vector>

int main() {
    using namespace matplot;

    auto theta = linspace(0, 2 * pi);
    auto x = transform(theta, [](double theta) { return cos(theta); });
    auto y = transform(theta, [](double theta) { return sin(theta); });
    auto z = theta;
    scatter3(x, y, z);

    zlim(manual);
    zlim({0, 2 * pi});
    hold(on);
    auto z2 = transform(theta, [](double theta) { return 5 * theta; });
    scatter3(x, y, z2);
    hold(off);

    show();
    return 0;
}

example_zlim_5

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <matplot/matplot.h>
#include <set>
#include <thread>
#include <vector>

int main() {
    using namespace matplot;

    auto theta = linspace(0, 2 * pi);
    auto x = transform(theta, [](double theta) { return cos(theta); });
    auto y = transform(theta, [](double theta) { return sin(theta); });
    auto z = theta;
    scatter3(x, y, z);

    zlim(manual);
    zlim({0, 2 * pi});
    hold(on);
    auto z2 = transform(theta, [](double theta) { return 5 * theta; });
    scatter3(x, y, z2);
    hold(off);

    zlim(automatic);

    show();
    return 0;
}

example_zlim_6

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <matplot/matplot.h>
#include <set>
#include <thread>
#include <vector>

int main() {
    using namespace matplot;

    tiledlayout(2, 1);

    auto x = randn(50, 0, 1);
    auto y = randn(50, 0, 1);
    auto z = randn(50, 0, 1);
    scatter3(x, y, z);

    auto zl = zlim();
    std::cout << "zl[0]: " << zl[0] << std::endl;
    std::cout << "zl[1]: " << zl[1] << std::endl;

    show();
    return 0;
}