Skip to content

X Tick Format

1
xtickformat(fmtstr);

example_xtickformat_1

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

int main() {
    using namespace matplot;

    auto x = iota(0, 20, 100);
    vector_1d y = {88, 67, 98, 43, 45, 65};
    bar(x, y);
    xtickformat("usd");

    show();
    return 0;
}

More examples

example_xtickformat_2

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

int main() {
    using namespace matplot;

    auto x = iota(0, 20, 100);
    vector_1d y = {88, 67, 98, 43, 45, 65};
    bar(x, y);
    xtickformat("usd");
    std::cout << "xtickformat(): " << xtickformat() << std::endl;
    xtickformat("$%.0f");

    show();
    return 0;
}

example_xtickformat_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 = iota(0, 10);
    vector_1d y = {.17, .25, .27, .28, .3, .32, .33, .34, .345, .35};
    plot(x, y, "-v");
    xtickformat("%g GHz");

    show();
    return 0;
}

example_xtickformat_4

 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 = linspace(0, 1, 100);
    vector_1d y = transform(x, randn(100, 0., 1.),
                            [](double x, double r) { return r * cos(x); });
    scatter(x, y);
    xtickformat("%.2f");

    show();
    return 0;
}

example_xtickformat_5

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

int main() {
    using namespace matplot;

    tiledlayout(2, 1);

    auto ax1 = nexttile();
    plot(ax1, rand(6, 6, 0, 1));

    auto ax2 = nexttile();
    plot(ax2, rand(6, 6, 0, 1));

    xtickformat(ax2, "usd");

    show();
    return 0;
}