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

Detailed Description

View in nbviewer Open in SWAN
Draw a scatter plot.

void scatter()
{
auto canvas = new TCanvas();
canvas->SetRightMargin(0.14);
gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette
const int n = 175;
double x[n];
double y[n];
double c[n];
double s[n];
// Define four random data set
auto r = new TRandom();
for (int i = 0; i < n; i++) {
x[i] = 100 * r->Rndm(i);
y[i] = 200 * r->Rndm(i);
c[i] = 300 * r->Rndm(i);
s[i] = 400 * r->Rndm(i);
}
auto scatter = new TScatter(n, x, y, c, s);
scatter->SetMarkerStyle(20);
scatter->SetTitle("Scatter plot title;X title;Y title;Z title");
scatter->GetXaxis()->SetRangeUser(20., 90.);
scatter->GetYaxis()->SetRangeUser(55., 90.);
scatter->GetZaxis()->SetRangeUser(10., 200.);
scatter->Draw("A");
}
#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
Author
Olivier Couet

Definition in file scatter.C.