forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binscatter_3.cpp
52 lines (40 loc) · 1.2 KB
/
binscatter_3.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <matplot/matplot.h>
#include <random>
#include <tuple>
int main() {
using namespace matplot;
auto f = figure(true);
f->width(f->width() * 2);
f->height(f->height() * 2);
f->x_position(200);
f->y_position(100);
auto x = randn(1000000, 0., 1.);
auto y = transform(x, [](double x) { return 2 * x + randn(0, 1); });
bin_scatter_style b = bin_scatter_style::automatic;
subplot(2, 3, 0);
binscatter(x, y, histogram::binning_algorithm::automatic, b);
axis(tight);
title("Automatic");
subplot(2, 3, 1);
binscatter(x, y, histogram::binning_algorithm::integers, b);
axis(tight);
title("Integers");
subplot(2, 3, 2);
binscatter(x, y, histogram::binning_algorithm::scott, b);
axis(tight);
title("Scott's rule");
subplot(2, 3, 3);
binscatter(x, y, histogram::binning_algorithm::fd, b);
axis(tight);
title("Freedman-Diaconis rule");
subplot(2, 3, 4);
binscatter(x, y, histogram::binning_algorithm::sqrt, b);
axis(tight);
title("Square root rule");
subplot(2, 3, 5);
binscatter(x, y, histogram::binning_algorithm::sturges, b);
axis(tight);
title("Sturges' rule");
f->show();
return 0;
}