Pour les aficionados d'IML voici un bel arbre de noël(j'ai pas IML donc code non testé, source de l'article en bas de page)
Code :
Template et rendu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 proc iml; /* define helper functions ROW and COL */ start row(x); /* return matrix m such that m[i,j] = i */ return( repeat( T(1:nrow(x)), 1, ncol(x) )); finish; start col(x); /* return matrix m such that m[i,j] = j */ return( repeat(1:ncol(x), nrow(x)) ); finish; /* parameters for the tree dimensions */ h = 100; w = h+1; b = int(h/10); M = j(w, h, .); /* initialize h x w matrix to missing */ x = col(M); /* column numbers */ y = w + 1 - row(M); /* reverse Y axis */ /* define the leafy portion of the tree */ TreeIdx = loc(y>b & y<=2*x & y<=-2*x+2*h); /* a triangle */ M[TreeIdx] = 0; /* place lights randomly within tree */ N = int(0.12*ncol(TreeIdx)); /* use 12% of tree area */ call randseed(1225); do i = 1 to 3; /* 3 colors */ idx = sample(TreeIdx, N, "WOR"); /* sample without replacement */ M[idx] = i; end; /* define the trunk */ width = int(b/2); TrunkIdx = loc( y<= b & abs(x-nrow(M)/2)<width ); M[TrunkIdx] = 4; /* write matrix in "long form" to SAS data set */ Row = row(M); /* row index */ Col = col(M); /* col index */ create Tree var {"Row" "Col" "M"}; append; close Tree; quit;
Source de l'article ici : http://blogs.sas.com/content/iml/201...s-tree-matrix/
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 proc template; define statgraph HeatmapTree; dynamic _X _Y _Z; begingraph; discreteattrmap name="christmastree"; value '.' / fillattrs=(color=WHITE); /* background color */ value '0' / fillattrs=(color=GREEN); /* tree color */ value '1' / fillattrs=(color=RED); /* ornament color 1 */ value '2' / fillattrs=(color=BLUE); /* ornament color 2 */ value '3' / fillattrs=(color=YELLOW); /* ornament color 3 */ value '4' / fillattrs=(color=BROWN); /* tree trunk color */ enddiscreteattrmap; discreteattrvar attrvar=Alias var=_Z attrmap="christmastree"; layout overlay / xaxisopts=(type=discrete display=none) yaxisopts=(type=discrete display=none reverse=true); heatmapparm x=_X y=_Y colorgroup=Alias / xbinaxis=false ybinaxis=false primary=true; endlayout; endgraph; end; run; ods graphics / width=500 height=800; proc sgrender data=Tree template=HeatmapTree; dynamic _X="Col" _Y="Row" _Z="M"; run;
Joyeux Noël à tous !
Steel
Partager