BookmarkSubscribeRSS Feed
tanyuanbin
Calcite | Level 5
Hi,

In order to improve the capability and power of data discovery, I need to produce a plot with angled axes when using PROC GPLOT precedure, in another word, we need to automatically rotate both horizontal and vertical axes for some degrees, for example, 45 degree, can we do it? or if there were any alternative way to produce these angled lines like horizontal and vertical axes on the GLPOT chart?

It would be very much appreciated if anyone can help! Thank you for your time in advance!
8 REPLIES 8
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest reviewing the PROC GPLOT documentation and the AXIS statement parameter (ANGLE=). The SAS support http://support.sas.com/ website has SAS-hosted documentation and also supplemental technical / conference reference material.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:
proc gplot rotate axis value site:sas.com
ArtC
Rhodochrosite | Level 12
Assuming that you are asking for non-orthogonal axes, GPLOT does not have that capability - directly. There are work arounds. Using ANNOTATE you can build the graph including the axes. Using this method, my approach would be to build it first in a rectangular system and then convert the coordinates. I have used this for polar coordinate displays. An alternate is to convert first and then display on GPLOT (after hiding the carteasian axes).

PROC G3D has a ROTATE= option on the SCATTER statement which makes the axes appear to be non-orthogonal, though I doubt that will be helpful here.
GraphGuy
Meteorite | Level 14
Tan,

I just wanted to make sure ... you are wanting to rotate the axes, right? Not the tickmark text values, or the axis labels (it would be much easier to rotate the latter, of course! 🙂

Do you have a web url of a graph with rotated axes, similar to the graph you want? That would help us know exactly what the goal is!

Robert
tanyuanbin
Calcite | Level 5
Dear All,

First, I thank you all very much for your time and the useful information!

If we do not have a derect capability of non-orthogonal axes with GPLOT so far, can we rotate the orthogonal reference lines with some degrees, for example, 45 degrees? This should be also a good alternate.

I create a web url of the similar graph with rotated reference lines here at
http://www.baosuanpan.com/news/zt/2010-01-19/18.html for a better specification of the requirement. Thank you!
ArtC
Rhodochrosite | Level 12
This is not going to be straight forward. With annotate there are a couple of approaches that come to mind. Are the 45 degree lines relative to the horizontal axis alone or are they dependent on the scale of both the vertical and horizontal axis?

Here is a proof of concept example using annotate ignoring the vertical axis.
[pre]data anno(keep=function angle color line rotate when width
size xsys ysys hsys x y );
retain function 'pie' color 'blue' line 1 rotate 0 when 'a' width 2
xsys ysys '2' hsys '5' ;
size=100;
* Lines from horizontal axis;
y=50;
do x = 50 to 130 by 20;
angle=45;
output;
end;
do x = 90 to 170 by 20;
angle=135;
output;
end;
run;

symbol1 color='red' v=dot;
proc gplot data=sashelp.class anno=anno;
plot height*weight/haxis=50 to 170 by 20;
run;
quit;[/pre] Added the example

Message was edited by: ArtC
tanyuanbin
Calcite | Level 5
The sample is very helpful, and I tried to use them in my gplot procedure, the graph looks good, I put it here at
http://www.baosuanpan.com/news/zt/2010-01-19/13.html

Dear ArtC, can I bother you more seconds for a better output? the current displays is out of the range in terms of the vertical axis.
After doing a quick check about the Annotate Data Set, it seems to me that I need to define not only Y Variable but also others, is it? do you have more sample codes for this or any more advice? Thank you!
ArtC
Rhodochrosite | Level 12
The PIE variable defines a circular sector. With ROTATE=0 the subtended angle is 0 and we get just a line. ANGLE= the angle from the horizontal. SIZE= the radius or in our case the length of the line based on the horizontal axis. HSYS='2' causes the length of the line to be the same units as the horizontal axis. Now we can use math to calculate the length (SIZE) of the line when it comes to the sides. I start with 40 becasue it is 'about right' for this graph. Your numbers will change for your axes.

[pre]data anno(keep=function angle color line rotate when width
size xsys ysys hsys x y );
retain function 'pie' color 'blue' line 1 rotate 0 when 'a' width 2
xsys ysys '2' hsys '2' ;
title 'hsys 2';
* Lines from horizontal axis;
y=50;
do x = 50 to 150 by 20;
angle=45;
/* Size=length of line in horizontal units (HSYS=2)*/
if 170-x ge 40 then size=40;
else size = 170-x;
output;
end;
do x = 70 to 170 by 20;
angle=135;
if x-50 ge 40 then size=40;
else size = x-50;
output;
end;
run;
symbol1 color='red' v=dot;
proc gplot data=sashelp.class anno=anno;
plot height*weight/haxis=50 to 170 by 20;
run;quit;[/pre]

You can make the calculation of size more efficient or more complex depending on your needs.
tanyuanbin
Calcite | Level 5
Dear ArtC,

A better ouput and display was produced like this:
http://www.baosuanpan.com/news/zt/2010-01-19/17.html

It was a nice solution, thank you so much for your time and the great help!

Best Regards,
Tan

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
  • 8 replies
  • 922 views
  • 0 likes
  • 4 in conversation