Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gr019_scatter2d.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Draw a 2D scatter plot.

{
auto canvas = new TCanvas("canvas","canvas");
canvas->SetRightMargin(0.14);
gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette
const int n = 50;
double x1[n];
double y1[n];
double z1[n];
double c1[n];
double s1[n];
double x2[n];
double y2[n];
double z2[n];
double c2[n];
double s2[n];
// Define four random data set
auto r = new TRandom();
for (int i=0; i<n; i++) {
x1[i] = 100*r->Rndm(i);
y1[i] = 200*r->Rndm(i);
z1[i] = 10*r->Rndm(i);
c1[i] = 10000*r->Rndm(i);
s1[i] = 10000*r->Rndm(i);
x2[i] = 100*r->Rndm(i);
y2[i] = 200*r->Rndm(i);
z2[i] = 10*r->Rndm(i);
c2[i] = 5000*r->Rndm(i);
s2[i] = 100*r->Rndm(i);
}
c1[0] = 1;
auto scatter1 = new TScatter2D(n, x1, y1, z1, c1, s1);
scatter1->SetTitle("Scatter plot title;X title;Y title;Z title");
scatter1->SetMarkerStyle(20);
auto scatter2 = new TScatter2D(n, x2, y2, z2, c2, s2);
scatter2->SetMarkerStyle(21);
canvas->SetLogx();
scatter1->Draw("logc");
scatter2->Draw("SAME");
}
#define s1(x)
Definition RSha256.hxx:91
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kBird
Definition TColor.h:121
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
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
The Canvas class.
Definition TCanvas.h:23
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
A TScatter2D is able to draw five variables scatter plot on a single plot.
Definition TScatter2D.h:32
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1889
return c1
Definition legend1.C:41
const Int_t n
Definition legend1.C:16
return c2
Definition legend2.C:14
Author
Olivier Couet

Definition in file gr019_scatter2d.C.