BookmarkSubscribeRSS Feed
amrit11
Obsidian | Level 7

Is there a way that we can specify or assign a specific colour to a particular range of absolute values in a surface plot in proc g3d

eg :

rangeattrmap name="yield_map";

range 0-8 / rangecolormodel = (black );
range 8.02-8.88 / rangecolormodel=(darkred);
range 8.88-9.74/ rangecolormodel=(red);
range 9.74-10.6 / rangecolormodel=(yellow);
range 10.6 - 11.46 / rangecolormodel=(green);
range 11.46-12.32/ rangecolormodel=(darkgreen);
endrangeattrmap;

 or 

specify colours using "if - then - else" type of statments

 

without implementing a large number of macros as in eg : https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/Is-it-possible-to-specify-x-y-and-z-axis-l...

 

I also want to specify the length and range of the x y and z axes in the surface plot such that it looks rectangular like my data.

my  code is :

 

ods _all_ close;
ods html file="/home/amrit.genetics0/created for HTML output/s25264new.htm";

/* Set the DEVICE on the GOPTIONS statement */
/* to ACTIVEX. */
goptions reset=all device=activex
border xpixels=600 ypixels=400
cback=white;


Data surface_data;
input longitude latitude yield;
datalines;

25 1 9.4375
25 2 9.505882353
25 3 9.431578947
25 4 9.363636364
25 5 9.445454545
25 6 9.457142857
25 7 9.48
25 8 9.231578947
25 9 9.171428571
25 10 8.92
25 11 8.866666667
25 12 .
25 13 .
24 1 9.323076923
24 2 9.3125
24 3 9.305263158
24 4 9.2
24 5 9.27826087
24 6 9.228571429
24 7 9.126315789
24 8 8.805263158
24 9 8.735714286
24 10 8.49
24 11 8.385714286
24 12 .
24 13 .
23 1 9.4
23 2 9.2
23 3 9.235294118
23 4 9.180952381
23 5 9.19047619
23 6 9.022222222
23 7 9.053333333
23 8 8.65625
23 9 8.558333333
23 10 8.366666667
23 11 8.328571429
23 12 8.02
23 13 .
22 1 9.05
22 2 9.030769231
22 3 9.033333333
22 4 9.133333333
22 5 9.2
22 6 9.188235294
22 7 9.242857143
22 8 8.976923077
22 9 8.75
22 10 8.585714286
22 11 8.45
22 12 .
22 13 .
21 1 9.036363636
21 2 9.0875
21 3 8.99
21 4 9.019047619
21 5 9.136842105
21 6 9.106666667
21 7 9.066666667
21 8 8.75
21 9 8.6125
21 10 8.516666667
21 11 8.34
21 12 .
21 13 .
20 1 9.357142857
20 2 9.477777778
20 3 9.257142857
20 4 9.2
20 5 9.258823529
20 6 9.216666667
20 7 8.9
20 8 8.18
20 9 .
20 10 .
20 11 .
20 12 .
20 13 .
19 1 9.941176471
19 2 9.92
19 3 9.59047619
19 4 9.5
19 5 9.357142857
19 6 9.288888889
19 7 .
19 8 .
19 9 .
19 10 .
19 11 .
19 12 .
19 13 .
18 1 9.98
18 2 10.10434783
18 3 9.92173913
18 4 9.831578947
18 5 9.728571429
18 6 9.955555556
18 7 .
18 8 .
18 9 .
18 10 .
18 11 .
18 12 .
18 13 .
17 1 10.08181818
17 2 10.216
17 3 10.04166667
17 4 10.02105263
17 5 9.828571429
17 6 9.955555556
17 7 .
17 8 .
17 9 .
17 10 .
17 11 .
17 12 .
17 13 .
16 1 10.36363636
16 2 10.49166667
16 3 10.42608696
16 4 10.44444444
16 5 10.04615385
16 6 10.2
16 7 .
16 8 .
16 9 .
16 10 .
16 11 .
16 12 .
16 13 .
15 1 10.42
15 2 10.4
15 3 10.37142857
15 4 10.475
15 5 10
15 6 10.08571429
15 7 .
15 8 .
15 9 .
15 10 .
15 11 .
15 12 .
15 13 .
14 1 10.03157895
14 2 10.03478261
14 3 10.15238095
14 4 10.2625
14 5 9.927272727
14 6 9.914285714
14 7 .
14 8 .
14 9 .
14 10 .
14 11 .
14 12 .
14 13 .
13 1 9.652631579
13 2 9.634782609
13 3 9.552380952
13 4 9.7875
13 5 9.290909091
13 6 9.228571429
13 7 .
13 8 .
13 9 .
13 10 .
13 11 .
13 12 .
13 13 .
12 1 9.747368421
12 2 9.747826087
12 3 9.761904762
12 4 9.9875
12 5 9.6
12 6 9.657142857
12 7 .
12 8 .
12 9 .
12 10 .
12 11 11.44
12 12 12.1
12 13 12.32
11 1 9.7
11 2 9.709090909
11 3 9.72
11 4 9.946666667
11 5 9.5
11 6 9.571428571
11 7 .
11 8 .
11 9 .
11 10 .
11 11 11.56666667
11 12 12.11428571
11 13 12.3
10 1 9.564705882
10 2 9.59
10 3 9.621052632
10 4 9.728571429
10 5 9.466666667
10 6 9.533333333
10 7 10.04
10 8 .
10 9 11.36666667
10 10 11.37142857
10 11 11.62
10 12 12
10 13 12.1
9 1 9.505882353
9 2 9.6
9 3 9.435294118
9 4 9.583333333
9 5 9.4
9 6 9.68
9 7 10.56666667
9 8 11.8
9 9 11.85
9 10 11.64
9 11 11.81428571
9 12 12
9 13 12.03333333
8 1 9.611111111
8 2 9.682352941
8 3 9.546666667
8 4 9.36
8 5 9.36
8 6 .
8 7 11
8 8 11.8
8 9 11.675
8 10 11.52727273
8 11 11.8
8 12 11.76
8 13 11.7
7 1 9.431578947
7 2 9.529411765
7 3 9.56
7 4 9.36
7 5 9.64
7 6 .
7 7 11.71428571
7 8 12.05714286
7 9 11.74545455
7 10 11.66666667
7 11 11.87368421
7 12 11.61111111
7 13 11.63529412
6 1 9.2
6 2 9.329411765
6 3 9.24
6 4 9.2
6 5 9.975
6 6 10.675
6 7 11.36363636
6 8 11.45
6 9 11.38666667
6 10 11.42105263
6 11 11.60909091
6 12 11.42857143
6 13 11.59
5 1 9.345454545
5 2 9.515789474
5 3 9.541176471
5 4 9.657142857
5 5 10.33333333
5 6 10.95
5 7 11.26666667
5 8 11.425
5 9 11.41111111
5 10 11.24761905
5 11 11.40869565
5 12 11.24545455
5 13 11.27619048
4 1 9.365217391
4 2 9.45
4 3 9.610526316
4 4 9.964705882
4 5 10.5
4 6 11.225
4 7 11.36842105
4 8 11.4
4 9 11.27368421
4 10 11.19047619
4 11 11.28181818
4 12 11.16190476
4 13 11.21818182
3 1 9.454545455
3 2 9.580952381
3 3 9.904761905
3 4 10.27
3 5 10.58947368
3 6 11.23
3 7 11.54545455
3 8 11.71428571
3 9 11.76190476
3 10 11.64347826
3 11 11.6
3 12 11.51428571
3 13 11.42857143
2 1 9.511111111
2 2 9.577777778
2 3 9.831578947
2 4 10.25263158
2 5 10.52
2 6 11.18095238
2 7 11.46956522
2 8 11.76363636
2 9 11.88181818
2 10 11.79130435
2 11 11.67272727
2 12 11.63157895
2 13 11.37777778
1 1 9.6
1 2 9.613333333
1 3 9.882352941
1 4 10.22352941
1 5 10.44705882
1 6 11.41111111
1 7 11.66
1 8 12.18888889
1 9 12.28421053
1 10 12.14
1 11 11.93333333
1 12 11.85333333
1 13 11.32857143
;

proc g3grid data=SURFACE_DATA out=GRIDDED;
grid LONGITUDE*LATITUDE=YIELD / spline smooth=0.01
axis1=1 to 25 by .2
axis2=1 to 13 by .2;
run;

axis1 order=(0 to 25 by 5);
axis2 order=(0 to 25 by 5);
axis3 order=(0 to 50 by 5);

goptions colors = ( blueviolet blue aquamarine green yellow orangered red );

proc g3d data=GRIDDED ;
plot LATITUDE*LONGITUDE=YIELD / style=4 contour=1 grid xytype=0
xaxis=axis1 yaxis=axis2 zaxis=axis3;
run;

 

quit;
ODS HTML CLOSE;
ODS LISTING;

1 REPLY 1
GraphGuy
Meteorite | Level 14

I'm not sure about controlling that with device=activex, but I don't think there's a way to control the color of the g3d surface plot like you're wanting in the traditional g3d surface plots. If you use a scatter plot rather than a surface plot, you can get something fairly close ...

 

proc g3grid data=SURFACE_DATA out=GRIDDED;
grid LONGITUDE*LATITUDE=YIELD / spline smooth=0.01
axis1=1 to 25 by .5
axis2=1 to 13 by .5;
run;

data gridded; set gridded;
length colorval $12;
if yield<=8 then colorvar='black';
else if yield<=8.88 then colorval='darkred';
else if yield<=9.74 then colorval='red';
else if yield<=10.6 then colorval='yellow';
else if yield<=11.46 then colorval='green';
else colorval='darkgreen';
run;
proc g3d data=GRIDDED ;
scatter LATITUDE*LONGITUDE=YIELD /
shape='balloon' color=colorval rotate=25 /*noneedle*/
grid zmin=0 zmax=20 zticknum=5;
run;

 

surface.png

There is a very old example (from the V6 SAS/Graph Examples book) that shows how to annotate a colored surface plot onto a set of g3d axes, that you might could modify to produce what looks like a colored surface plot:

 

http://support.sas.com/kb/24/861.html

 

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 966 views
  • 0 likes
  • 2 in conversation