Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- GRAPH -Can we produce gplot with angled axes?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-15-2011 09:53 AM
(1410 views)

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!

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Scott Barry

SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

proc gplot rotate axis value site:sas.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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!

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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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!

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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

[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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

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 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.

Ready to level-up your skills? Choose your own adventure.