ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
parallelcoordtrans.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tree
3 ///
4 /// Use of transparency with ||-Coord.
5 /// It displays the same data set twice. The first time without transparency and
6 /// the second time with transparency. On the second plot, several clusters
7 /// appear.
8 /// ## Images without and with transparency
9 /// \macro_image
10 /// \macro_code
11 /// \author Olivier Couet
12 
13 #include "TFile.h"
14 #include "TCanvas.h"
15 #include "TStyle.h"
16 #include "TRandom.h"
17 #include "TNtuple.h"
18 #include "TParallelCoord.h"
19 #include "TParallelCoordVar.h"
20 #include "TParallelCoordRange.h"
21 
23 Double_t dr = 3.5;
24 TRandom *r;
25 
26 void generate_random(Int_t i) {
27  r->Rannor(r1,r4);
28  r->Rannor(r7,r9);
29  r2 = (2*dr*r->Rndm(i))-dr;
30  r3 = (2*dr*r->Rndm(i))-dr;
31  r5 = (2*dr*r->Rndm(i))-dr;
32  r6 = (2*dr*r->Rndm(i))-dr;
33  r8 = (2*dr*r->Rndm(i))-dr;
34 }
35 
36 void parallelcoordtrans() {
37  Double_t x,y,z,u,v,w,a,b,c;
38  Double_t s1x, s1y, s1z;
39  Double_t s2x, s2y, s2z;
40  Double_t s3x, s3y, s3z;
41  r = new TRandom();;
42 
43  TCanvas *c1 = new TCanvas("c1", "c1",0,0,900,1000);
44  c1->Divide(1,2);
45 
46  TNtuple *nt = new TNtuple("nt","Demo ntuple","x:y:z:u:v:w:a:b:c");
47 
48  int n=0;
49  for (Int_t i=0; i<1500; i++) {
50  r->Sphere(s1x, s1y, s1z, 0.1);
51  r->Sphere(s2x, s2y, s2z, 0.2);
52  r->Sphere(s3x, s3y, s3z, 0.05);
53 
54  generate_random(i);
55  nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
56  n++;
57 
58  generate_random(i);
59  nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z, r7, r8, r9);
60  n++;
61 
62  generate_random(i);
63  nt->Fill(r1, r2, r3, r4, r5, r6, r7, s3y, r9);
64  n++;
65 
66  generate_random(i);
67  nt->Fill(s2x-1, s2y-1, s2z, s1x+.5, s1y+.5, s1z+.5, r7, r8, r9);
68  n++;
69 
70  generate_random(i);
71  nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
72  n++;
73 
74  generate_random(i);
75  nt->Fill(s1x+1, s1y+1, s1z+1, s3x-2, s3y-2, s3z-2, r7, r8, r9);
76  n++;
77 
78  generate_random(i);
79  nt->Fill(r1, r2, r3, r4, r5, r6, s3x, r8, s3z );
80  n++;
81  }
82 
83  TParallelCoordVar* pcv;
84 
85  c1->cd(1);
86 
87  // ||-Coord plot without transparency
88  nt->Draw("x:y:z:u:v:w:a:b:c","","para");
89  TParallelCoord* para1 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
90  para1->SetLineColor(25);
91  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("x"); pcv->SetHistogramHeight(0.);
92  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("y"); pcv->SetHistogramHeight(0.);
93  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("z"); pcv->SetHistogramHeight(0.);
94  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("a"); pcv->SetHistogramHeight(0.);
95  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("b"); pcv->SetHistogramHeight(0.);
96  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("c"); pcv->SetHistogramHeight(0.);
97  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("u"); pcv->SetHistogramHeight(0.);
98  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("v"); pcv->SetHistogramHeight(0.);
99  pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("w"); pcv->SetHistogramHeight(0.);
100 
101 
102  // ||-Coord plot with transparency
103  TColor *col26 = gROOT->GetColor(26); col26->SetAlpha(0.01);
104  c1->cd(2);
105  nt->Draw("x:y:z:u:v:w:a:b:c","","para");
106  TParallelCoord* para2 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
107  para2->SetLineColor(26);
108  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("x"); pcv->SetHistogramHeight(0.);
109  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("y"); pcv->SetHistogramHeight(0.);
110  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("z"); pcv->SetHistogramHeight(0.);
111  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("a"); pcv->SetHistogramHeight(0.);
112  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("b"); pcv->SetHistogramHeight(0.);
113  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("c"); pcv->SetHistogramHeight(0.);
114  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("u"); pcv->SetHistogramHeight(0.);
115  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("v"); pcv->SetHistogramHeight(0.);
116  pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("w"); pcv->SetHistogramHeight(0.);
117 
118  // Produce transparent lines in interactive and batch mode
119  c1->Print("parallelcoordtrans.pdf");
120  c1->Print("parallelcoordtrans.svg");
121 
122  // Produce transparent lines in batch mode only
123  c1->Print("parallelcoordtrans.gif");
124  c1->Print("parallelcoordtrans.jpg");
125  c1->Print("parallelcoordtrans.png");
126 }
virtual void SetAlpha(Float_t a)
Definition: TColor.h:95
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:460
void SetLineColor(Color_t col)
Double_t r6
Definition: parallelcoord.C:13
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition: TRandom.cxx:512
return c
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
#define gROOT
Definition: TROOT.h:344
int Int_t
Definition: RtypesCore.h:41
TArc * a
Definition: textangle.C:12
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Definition: TPad.cxx:4134
Double_t r8
Definition: parallelcoord.C:13
TParallelCoord axes.
Double_t x[n]
Definition: legend1.C:17
TList * GetVarList()
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
void parallelcoordtrans()
Float_t z[5]
Definition: Ifit.C:16
A simple TTree restricted to a list of float variables only.
Definition: TNtuple.h:30
SVector< double, 2 > v
Definition: Dict.h:5
Double_t r9
Definition: parallelcoord.C:13
Double_t r5
Definition: parallelcoord.C:13
tuple w
Definition: qtexample.py:51
The Canvas class.
Definition: TCanvas.h:48
void SetHistogramHeight(Double_t h=0)
Set the height of the bar histogram.
double Double_t
Definition: RtypesCore.h:55
Double_t r4
Definition: parallelcoord.C:13
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:360
Double_t y[n]
Definition: legend1.C:17
virtual Int_t Fill()
[fNvar] Array of variables
Definition: TNtuple.cxx:168
The color creation and management class.
Definition: TColor.h:47
virtual void Sphere(Double_t &x, Double_t &y, Double_t &z, Double_t r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
Definition: TRandom.cxx:588
Parallel Coordinates class.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1073
void generate_random(Int_t i)
Definition: parallelcoord.C:17
Double_t r7
Definition: parallelcoord.C:13
#define gPad
Definition: TVirtualPad.h:288
Double_t dr
Definition: parallelcoord.C:14