forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallelcoordtrans.C
More file actions
135 lines (114 loc) · 4.59 KB
/
parallelcoordtrans.C
File metadata and controls
135 lines (114 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/// \file
/// \ingroup tutorial_tree
/// \notebook
/// Use of transparency with ||-Coord.
///
/// It displays the same data set twice. The first time without transparency and
/// the second time with transparency. On the second plot, several clusters
/// appear.
///
/// ### Images without and with transparency
///
/// \macro_image
///
/// ### Transparency works in PDF files
///
/// \macro_image (parallelcoordtrans.pdf)
///
/// \macro_code
///
/// \author Olivier Couet
#include "TFile.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TRandom.h"
#include "TNtuple.h"
#include "TParallelCoord.h"
#include "TParallelCoordVar.h"
#include "TParallelCoordRange.h"
Double_t r1,r2,r3,r4,r5,r6,r7,r8,r9;
Double_t dr = 3.5;
TRandom *r;
void generate_random(Int_t i) {
r->Rannor(r1,r4);
r->Rannor(r7,r9);
r2 = (2*dr*r->Rndm(i))-dr;
r3 = (2*dr*r->Rndm(i))-dr;
r5 = (2*dr*r->Rndm(i))-dr;
r6 = (2*dr*r->Rndm(i))-dr;
r8 = (2*dr*r->Rndm(i))-dr;
}
void parallelcoordtrans() {
Double_t x,y,z,u,v,w,a,b,c;
Double_t s1x, s1y, s1z;
Double_t s2x, s2y, s2z;
Double_t s3x, s3y, s3z;
r = new TRandom();;
TCanvas *c1 = new TCanvas("c1", "c1",0,0,900,1000);
c1->Divide(1,2);
TNtuple *nt = new TNtuple("nt","Demo ntuple","x:y:z:u:v:w:a:b:c");
int n=0;
for (Int_t i=0; i<1500; i++) {
r->Sphere(s1x, s1y, s1z, 0.1);
r->Sphere(s2x, s2y, s2z, 0.2);
r->Sphere(s3x, s3y, s3z, 0.05);
generate_random(i);
nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
n++;
generate_random(i);
nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z, r7, r8, r9);
n++;
generate_random(i);
nt->Fill(r1, r2, r3, r4, r5, r6, r7, s3y, r9);
n++;
generate_random(i);
nt->Fill(s2x-1, s2y-1, s2z, s1x+.5, s1y+.5, s1z+.5, r7, r8, r9);
n++;
generate_random(i);
nt->Fill(r1, r2, r3, r4, r5, r6, r7, r8, r9);
n++;
generate_random(i);
nt->Fill(s1x+1, s1y+1, s1z+1, s3x-2, s3y-2, s3z-2, r7, r8, r9);
n++;
generate_random(i);
nt->Fill(r1, r2, r3, r4, r5, r6, s3x, r8, s3z );
n++;
}
TParallelCoordVar* pcv;
c1->cd(1);
// ||-Coord plot without transparency
nt->Draw("x:y:z:u:v:w:a:b:c","","para");
TParallelCoord* para1 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
para1->SetLineColor(25);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("x"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("y"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("z"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("a"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("b"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("c"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("u"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("v"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para1->GetVarList()->FindObject("w"); pcv->SetHistogramHeight(0.);
// ||-Coord plot with transparency
TColor *col26 = gROOT->GetColor(26); col26->SetAlpha(0.01);
c1->cd(2);
nt->Draw("x:y:z:u:v:w:a:b:c","","para");
TParallelCoord* para2 = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
para2->SetLineColor(26);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("x"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("y"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("z"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("a"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("b"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("c"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("u"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("v"); pcv->SetHistogramHeight(0.);
pcv = (TParallelCoordVar*)para2->GetVarList()->FindObject("w"); pcv->SetHistogramHeight(0.);
// Produce transparent lines in interactive and batch mode
c1->Print("parallelcoordtrans.pdf");
c1->Print("parallelcoordtrans.svg");
// Produce transparent lines in batch mode only
c1->Print("parallelcoordtrans.gif");
c1->Print("parallelcoordtrans.jpg");
c1->Print("parallelcoordtrans.png");
}