Scatter Plot
More examples
Plot
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <matplot/matplot.h>
#include <random>
int main () {
using namespace matplot ;
auto theta = linspace ( 0 , 2 * pi , 300 );
auto x =
transform ( theta , [ & ]( double t ) { return sin ( t ) + 0.75 * rand ( 0 , 1 ); });
auto y =
transform ( theta , [ & ]( double t ) { return cos ( t ) + 0.75 * rand ( 0 , 1 ); });
double sz = 6 ;
auto l = scatter ( x , y , sz );
l -> marker_color ({ 0.f , .5f , .5f });
l -> marker_face_color ({ 0.f , .7f , .7f });
show ();
return 0 ;
}
Scatter plots also depend on the line
object. As the line object can represent lines with markers, the scatter
function simply creates markers without the lines.