Sample 48432: Use SG Annotation to rotate axis values in SGPLOT procedure output
The sample code on the Full Code tab uses SG Annotation to rotate the X-axis values in output produced by the SGPLOT procedure.
Beginning with the third maintenance release of SAS® 9.4 (TS1M3), the VALUESROTATE=VERTICAL option on the XAXIS statement will allow values that overwrite to be rotated 90 degrees without the need for annotation. Values that do not overwrite will need to be annotated for vertical rotation.
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 SG Annotation to rotate the X-axis values in output produced by the SGPLOT procedure.
Beginning with the third maintenance release of SAS
® 9.4 (TS1M3), the VALUESROTATE=VERTICAL option on the XAXIS statement will allow values that overwrite to be rotated 90 degrees without the need for annotation. Values that do not overwrite will need to be annotated for vertical rotation.
/* Define a style to determine the color for each of the groups. */
proc template;
define style colors;
parent=styles.htmlblue;
style GraphData1 from GraphData1 / ContrastColor=cx0000CC Color=cx0000cc;
style GraphData2 from GraphData2 / ContrastColor=lip Color=lip;
end;
run;
/* Reference the style in the ODS destination statement. */
ods html style=colors gpath='c:\temp';
/* Create an annotate data set to place the axis values below
the axis with a rotation of 90 degrees. */
data sganno;
retain function 'text' x1space 'datavalue' y1space 'datapercent'
rotate 90 anchor "right" width 30 textweight 'bold';
length textcolor $20;
set sashelp.class;
label=name;
xc1=name;
y1=-5;
/* Make the color for the text the same as the group value.
Since "M" is encountered first in the data, GraphData1 is used. */
if sex="F" then textcolor='GraphData2:color';
else textcolor='GraphData1:color';
run;
title 'Use Annotate to Rotate Axis Values';
proc sgplot data=sashelp.class sganno=sganno pad=(bottom=15%);
scatter x=name y=weight / markerattrs=(symbol=squarefilled size=10px)
group=sex;
xaxis display=(nolabel novalues) offsetmin=0.02 offsetmax=0.02;
yaxis labelattrs=(weight=bold) valueattrs=(weight=bold);
keylegend / location=inside valueattrs=(weight=bold);
run;
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 SG Annotation to rotate the X-axis values in output produced by the SGPLOT procedure. Beginning with the third maintenance release of SAS® 9.4 (TS1M3), the VALUESROTATE=VERTICAL option on the XAXIS statement will allow values that overwrite to be rotated 90 degrees.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2012-11-12 10:41:19 |
Date Created: | 2012-11-08 10:59:25 |
Operating System and Release Information
SAS System | Base SAS | Aster Data nCluster on Linux x64 | 9.3 TS1M1 | |
DB2 Universal Database on AIX | 9.3 TS1M1 | |
DB2 Universal Database on Linux x64 | 9.3 TS1M1 | |
Greenplum on Linux x64 | 9.3 TS1M1 | |
Netezza TwinFin 32bit blade | 9.3 TS1M1 | |
Netezza TwinFin 32-bit SMP Hosts | 9.3 TS1M1 | |
Netezza TwinFin 64-bit S-Blades | 9.3 TS1M1 | |
Netezza TwinFin 64-bit SMP Hosts | 9.3 TS1M1 | |
Teradata on Linux | 9.3 TS1M1 | |
z/OS | 9.3 TS1M1 | |
Z64 | 9.3 TS1M1 | |
Microsoft® Windows® for x64 | 9.3 TS1M1 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M1 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M1 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M1 | |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M1 | |
Microsoft Windows Server 2008 | 9.3 TS1M1 | |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M1 | |
Microsoft Windows XP Professional | 9.3 TS1M1 | |
Windows 7 Enterprise 32 bit | 9.3 TS1M1 | |
Windows 7 Enterprise x64 | 9.3 TS1M1 | |
Windows 7 Home Premium 32 bit | 9.3 TS1M1 | |
Windows 7 Home Premium x64 | 9.3 TS1M1 | |
Windows 7 Professional 32 bit | 9.3 TS1M1 | |
Windows 7 Professional x64 | 9.3 TS1M1 | |
Windows 7 Ultimate 32 bit | 9.3 TS1M1 | |
Windows 7 Ultimate x64 | 9.3 TS1M1 | |
Windows Vista | 9.3 TS1M1 | |
Windows Vista for x64 | 9.3 TS1M1 | |
64-bit Enabled AIX | 9.3 TS1M1 | |
64-bit Enabled HP-UX | 9.3 TS1M1 | |
64-bit Enabled Solaris | 9.3 TS1M1 | |
HP-UX IPF | 9.3 TS1M1 | |
Linux | 9.3 TS1M1 | |
Linux for x64 | 9.3 TS1M1 | |
Solaris for x64 | 9.3 TS1M1 | |