Skip to content

Z Ticks

1
zticks(zs);

example_zticks_1

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

int main() {
    using namespace matplot;

    auto [x, y, z] = peaks();
    surf(x, y, z);
    zlim({-8, 8});
    zticks({-8, 0, +8});
    zticklabels({"z=-8", "z=0", "z=8"});

    show();
    return 0;
}

More examples

example_zticks_2

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

int main() {
    using namespace matplot;

    auto [x, y, z] = peaks();
    surf(x, y, z);
    zlim({-10, 10});
    zticks({-10, -2.5, 0, 2.5, 10});

    show();
    return 0;
}

example_zticks_3

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

int main() {
    using namespace matplot;

    auto [x, y, z] = peaks();
    surf(x, y, z);
    zlim({-10, 10});
    zticks(iota(-10, 2, 10));

    show();
    return 0;
}

example_zticks_4

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

int main() {
    using namespace matplot;

    auto t = iota(0, pi / 50, 10 * pi);
    auto st = transform(t, [](double t) { return sin(t); });
    auto ct = transform(t, [](double t) { return cos(t); });
    plot3(st, ct, t);
    zlim({0, 40});
    zticks(iota(0, 8, 40));
    zticks(automatic);

    show();
    return 0;
}

example_zticks_5

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

int main() {
    using namespace matplot;

    tiledlayout(2, 1);
    auto ax1 = nexttile();
    stem3(ax1, rand(5, 5, 0, 4));
    zticks(ax1, {0, 1.5, 3.25});

    auto ax2 = nexttile();
    stem3(ax2, rand(5, 5, 0, 4));

    show();
    return 0;
}

example_zticks_6

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

int main() {
    using namespace matplot;

    auto [x, y, z] = peaks();
    mesh(x, y, z);
    zticks({});
    box(off);

    show();
    return 0;
}