Skip to content

Title

1
title(str);

example_title_1

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

int main() {
    using namespace matplot;
    auto x = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    title("My title");

    show();
    return 0;
}

More examples

example_title_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 = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    double f = 70.;
    double c = (f - 32) / 1.8;
    title("Temperature is " + num2str(c) + " C");

    show();
    return 0;
}

example_title_3

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

int main() {
    using namespace matplot;
    auto x = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    title("Case number # 3", "m");

    show();
    return 0;
}

example_title_4

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

int main() {
    using namespace matplot;
    auto t = iota(0, 0.01, 0.2);
    auto y = transform(t, [](double x) { return exp(-25 * x); });
    plot(t, y);
    title("y = {/:Italic e^{λt}}", "b");

    show();
    return 0;
}

example_title_5

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

int main() {
    using namespace matplot;
    auto x = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    title("α^2 and X_1");

    show();
    return 0;
}

example_title_6

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

int main() {
    using namespace matplot;
    auto x = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    title("First line\\nSecond line");

    show();
    return 0;
}

example_title_7

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

int main() {
    using namespace matplot;
    auto x = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    plot(x);
    title("X_1");
    gca()->title_enhanced(false);

    show();
    return 0;
}

example_title_8

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

int main() {
    using namespace matplot;
    auto x1 = transform(iota(1, 10), [](double x) { return pow(x, 2); });
    auto x2 = transform(iota(1, 10), [](double x) { return pow(x, 3); });

    tiledlayout(2, 1);

    auto ax1 = nexttile();
    plot(ax1, x1);

    auto ax2 = nexttile();
    plot(ax2, x2);

    title(ax1, "Top Plot");
    title(ax2, "Bottom Plot");

    show();
    return 0;
}