Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
scatter.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// Draw a scatter plot.
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Olivier Couet
10
11void scatter()
12{
13 auto canvas = new TCanvas();
14 gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette
15
16 const int n = 100;
17 double x[n];
18 double y[n];
19 double c[n];
20 double s[n];
21
22 // Define four random data set
23 auto r = new TRandom();
24 for (int i=0; i<n; i++) {
25 x[i] = 100*r->Rndm(i);
26 y[i] = 200*r->Rndm(i);
27 c[i] = 300*r->Rndm(i);
28 s[i] = 400*r->Rndm(i);
29 }
30
31 auto scatter = new TScatter(n, x, y, c, s);
32 scatter->SetMarkerStyle(20);
33 scatter->SetTitle("Scatter plot;X;Y");
34 scatter->Draw("A");
35}
#define c(i)
Definition RSha256.hxx:101
@ kBird
Definition TColor.h:116
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
The Canvas class.
Definition TCanvas.h:23
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
A TScatter is able to draw four variables scatter plot on a single plot.
Definition TScatter.h:32
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1884
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16