Skip to content

Clear Axes

1
cla();

example_cla_1

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

int main() {
    using namespace matplot;

    auto x = linspace(0, 2 * pi);
    auto y1 = transform(x, [](double x) { return sin(x); });
    plot(x, y1);

    hold(on);
    auto y2 = transform(x, [](double x) { return sin(2 * x); });
    plot(x, y2);

    cla();

    auto y3 = transform(x, [](double x) { return sin(3 * x); });
    plot(x, y3);
    hold(off);

    show();
    return 0;
}

More examples

example_cla_2

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

int main() {
    using namespace matplot;

    tiledlayout(2, 1);
    auto ax1 = nexttile();
    auto [x, y, z] = peaks();
    surf(x, y, z);

    auto ax2 = nexttile();
    contour(x, y, z);

    cla(ax1);

    show();
    return 0;
}

example_cla_3

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

int main() {
    using namespace matplot;

    auto x = linspace(0, 2 * pi);
    auto y = transform(x, [](double x) { return sin(x); });
    plot(x, y);
    axis({0, 5, -2, 2});
    cla();

    show();
    return 0;
}