Skip to content

Y Tick Format

1
ytickformat(fmtstr);

example_ytickformat_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);
    ytickformat("usd");

    show();
    return 0;
}

More examples

example_ytickformat_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);
    ytickformat("usd");
    std::cout << "ytickformat(): " << ytickformat() << std::endl;
    ytickformat("$%.0f");

    show();
    return 0;
}

example_ytickformat_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, 33, 32, 33, 34, 33, 35};
    plot(x, y, "-V");
    ytickformat("%g M");

    show();
    return 0;
}

example_ytickformat_4

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

int main() {
    using namespace matplot;

    auto x = rand(30, 0, 1);
    auto y = rand(30, 0, 1);
    scatter(x, y);
    ytickformat("%.2f");

    show();
    return 0;
}

example_ytickformat_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));

    ytickformat(ax2, "usd");

    show();
    return 0;
}