Date: Tue, 18 May 2004 13:38:23 -0600
Reply-To: Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Subject: Re: Plotting spectrum colors
Content-Type: text/plain; charset=us-ascii
Dale,
I'd suggest looking at one of the several papers by Perry Watts from
recent SUGIs which describe color coding schemes and how to create color
charts and scales.
You can find a list of the papers at Lex Jansen's site:
http://www.lexjansen.com/sugi/index.htm
by searching on Perry Watts.
Ken
>>> "Dale McLerran" <stringplayer_2@YAHOO.COM> 05/18/04 12:19PM >>>
Hi folks,
I am working on a macro to produce heat maps. Heat maps use either
a gray scale gradient or a color gradient to represent a third
dimension of some data. When using a color gradient, my intensities
should follow the colors of a rainbow. That is, low intensities
should be represented by violet and high intensities by red. I
thought that generating colors employing the HLS color system
(see http://v8doc.sas.com/sashtml/gref/zgscheme.htm) would be the
easiest way to follow the colors of the rainbow. If I understand
the HLS color system, violet begins at 90 degrees and red ends
at 90 degrees with direction of travel around the circle through
decreasing degrees. That led me to write the following code which
uses 90 pattern statements each at 4 degree offsets from the last
pattern statement going around the circle.
%macro heatmap;
%do k=1 %to 90;
%let deg=%sysfunc(putn(%sysfunc(mod(360+92-4*&k,360)),z3.));
%* %let deg=%sysfunc(putn(%eval((&k-1)*4),z3.));
pattern&k value=msolid color=h°.7595;
%end;
data colors;
do obs=1 to 2;
do mz=0 to 89;
intensity=mz;
output;
end;
end;
run;
proc gcontour data=colors;
plot obs*mz=intensity / levels=0 to 89 by 1 pattern;
run;
quit;
%mend;
options mprint;
%heatmap
When I run this code, the colors are produced do not seem to follow
the color wheel at all. It appears to start with red, then go to
the violets and blues, skip the greens and yellows and go to orange
followed by red and violet, then produce greens, yellows, orange,
violet again, then blues, greens, and oranges. Thus, we appear
to go around the color wheel several times, but skip certain colors
along the way.
Can anyone tell me why I am not going around the color wheel once
with the code shown above? Is there some other way to define
colors following a smooth gradient around the color wheel?
Thanks,
Dale
p.s. I should note that I have no trouble with a gray-scale
heatmap. The following code shows that defining shades of gray
works just fine.
%macro heatmap_gray;
%let k=0;
%do i=0 %to 15;
%let hexi = %sysfunc(putn(&i,hex1.));
%do j=0 %to 12 %by 4;
%let hexj = %sysfunc(putn(&j,hex1.));
%let k=%eval(&k+1);
pattern&k value=msolid color=gray&hexi.&hexj;
%end;
%end;
data colors;
do obs=1 to 2;
do mz=0 to 63;
intensity=mz;
output;
end;
end;
run;
proc gcontour data=colors;
plot obs*mz=intensity / levels=0 to 63 by 1 pattern;
run;
quit;
%mend;
%heatmap_gray
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/