Skip to content

Figure Object

1
figure();

example_figure_1

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

int main() {
    using namespace matplot;

    auto h = figure();
    auto ax = h->current_axes();
    fplot(ax, "cos(x)");

    show();
    return 0;
}

More examples

example_figure_2

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

int main() {
    using namespace matplot;

    auto h = figure(true);
    h->name("Measured Data");
    h->number_title(false);
    h->color("green");
    h->position({0, 0, 600, 600});
    h->size(500, 500);
    h->draw();
    h->font("Arial");
    h->font_size(40);
    h->title("My experiment");

    constexpr float pi_f = 3.14f;
    axis({-pi_f, pi_f, -1.5f, +1.5f});
    fplot("cos(x)");
    h->draw();
    show();
    return 0;
}

example_figure_3

 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 f1 = figure();
    auto f2 = figure();
    plot(vector_1d{1., 2., 3.}, vector_1d{2., 4., 6.});

    figure(f1);
    scatter(iota(1, 20), rand(20, 0, 1));

    show();
    return 0;
}