Sample 49070: Add gradient shading behind a graph
The sample code on the
Full Code tab uses the BAND statement in PROC SGPLOT to add gradient colors behind the graph elements.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below uses the BAND statement in PROC SGPLOT to add gradient colors behind the graph elements.
ods path(prepend) work.template(update);
proc template;
define style Gridlines ;
parent = styles.default;
style GraphGridLines from GraphGridLines /
contrastcolor=black;
end;
run;
ods listing close;
ods html file='test.html' path='c:\temp' style=gridlines;
ods graphics / reset;
data sample;
do x=1 to 20;
y=ranuni(123)*100;
output;
end;
run;
proc sql noprint;
select max(y)*.33, max(y)*.66, round(max(y),10) into :first, :middle, :max
from sample;
quit;
/* Specify the number of bands of color */
%let numbands=8;
/* Define each of the colors for the gradient */
%let color1=cxF7FCF5;
%let color2=cxE5F5E0;
%let color3=cxC7E9C0;
%let color4=cxA1D99B;
%let color5=cx74C476;
%let color6=cx41AB5D;
%let color7=cx238B45;
%let color8=cx005A32;
%macro bands;
%do i=1 %to &numbands;
band x=x lower=%sysevalf(&max*(1/&numbands)*(&i-1)) upper=%sysevalf(&max*(1/&numbands)*&i) /
fill fillattrs=(color=&&color&i) transparency=0.4;
%end;
%mend;
title 'Graph with Gradient Background';
proc sgplot data=sample;
/* Generate the bands through a macro */
%bands;
scatter x=x y=y / name='scatter' legendlabel='Y Value' markerattrs=(symbol=circlefilled);
yaxis min=0 offsetmin=0 offsetmax=0 grid label="Y Axis Value";
xaxis label="X Axis Value";
keylegend 'scatter';
run;
ods html close;
ods listing;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample uses the BAND statement in PROC SGPLOT to add gradient colors behind the graph elements.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2013-02-08 11:04:57 |
Date Created: | 2013-02-05 09:56:13 |
Operating System and Release Information
SAS System | SAS/GRAPH | Windows 7 Home Premium x64 | 9.2 TS2M2 | |
Windows 7 Home Premium 32 bit | 9.2 TS2M2 | |
Windows 7 Enterprise x64 | 9.2 TS2M2 | |
Windows 7 Enterprise 32 bit | 9.2 TS2M2 | |
Microsoft Windows XP Professional | 9.2 TS2M2 | |
Microsoft Windows Server 2008 for x64 | 9.2 TS2M2 | |
Microsoft Windows Server 2008 | 9.2 TS2M2 | |
Microsoft Windows Server 2003 for x64 | 9.2 TS2M2 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS2M2 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS2M2 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS2M2 | |
Microsoft® Windows® for x64 | 9.2 TS2M2 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS2M2 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS2M2 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS2M2 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS2M2 | |
z/OS | 9.2 TS2M2 | |
Windows 7 Professional 32 bit | 9.2 TS2M2 | |
Windows 7 Professional x64 | 9.2 TS2M2 | |
Windows 7 Ultimate 32 bit | 9.2 TS2M2 | |
Windows 7 Ultimate x64 | 9.2 TS2M2 | |
Windows Vista | 9.2 TS2M2 | |
Windows Vista for x64 | 9.2 TS2M2 | |
64-bit Enabled AIX | 9.2 TS2M2 | |
64-bit Enabled HP-UX | 9.2 TS2M2 | |
64-bit Enabled Solaris | 9.2 TS2M2 | |
HP-UX IPF | 9.2 TS2M2 | |
Linux | 9.2 TS2M2 | |
Linux for x64 | 9.2 TS2M2 | |
OpenVMS on HP Integrity | 9.2 TS2M2 | |
Solaris for x64 | 9.2 TS2M2 | |