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 canvas->SetRightMargin(0.14);
15 gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette
16
17 const int n = 175;
18 double x[n];
19 double y[n];
20 double c[n];
21 double s[n];
22
23 // Define four random data set
24 auto r = new TRandom();
25 for (int i = 0; i < n; i++) {
26 x[i] = 100 * r->Rndm(i);
27 y[i] = 200 * r->Rndm(i);
28 c[i] = 300 * r->Rndm(i);
29 s[i] = 400 * r->Rndm(i);
30 }
31
32 auto scatter = new TScatter(n, x, y, c, s);
33 scatter->SetMarkerStyle(20);
34 scatter->SetTitle("Scatter plot title;X title;Y title;Z title");
35 scatter->GetXaxis()->SetRangeUser(20., 90.);
36 scatter->GetYaxis()->SetRangeUser(55., 90.);
37 scatter->GetZaxis()->SetRangeUser(10., 200.);
38 scatter->Draw("A");
39}
#define c(i)
Definition RSha256.hxx:101
@ kBird
Definition TColor.h:118
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:436
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:1888
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16