## Any reference for Creating rectangle on x-axis and y-axis range %28-50 to 50%29 for both.

Used SGPLOT polygon but it gives not whole rectangle form.

4 REPLIES 4

## Re: Any reference for Creating rectangle on x-axis and y-axis range %28-50 to 50%29 for both.

Please post your code (and data, if you can) and explain what you are trying to accomplish.

If it helps, the coordinates for the POLYGON statement are in the data coordinate system. So if you want a rectangle that goes from 28% of the data range to 50% of the data range, you can use PROC MEANS to compute the min and max values of the coordinates, then use a DATA step to create the rectangle corners, which will have the values

XMin_Poly = XMin + 0.28*(XMax - XMin);

XMax_Poly = XMin + 0.5*(XMax - XMin);

The Y coordinates are computed similarly.  Jay54
Meteorite | Level 14

## Re: Any reference for Creating rectangle on x-axis and y-axis range %28-50 to 50%29 for both.

I too prefer using POLYGON plot in data coordinates as suggested by Rick.  This is good if you want the figures to be represented in the legend, or be displayed in correct order.  If this is not required, annotation is an alternative. In that case you can use SGAnnotation (or %SGANNO macros) in DataPercent drawspace.  DanH_sas
SAS Super FREQ

## Re: Any reference for Creating rectangle on x-axis and y-axis range %28-50 to 50%29 for both.

I had the same thought as @Jay54 , because you can use DATAPERCENT as a drawing space. Here is a simple example:

``````data anno;
length function \$ 9 drawspace \$ 11 anchor \$ 10;
function="rectangle";
drawspace="datapercent";
anchor="bottomleft";
x1=28;
y1=29;
width=22;
height=21;
output;
run;

proc sgplot data=sashelp.class sganno=anno;
scatter x=weight y=height;
run;``````

## Re: Any reference for Creating rectangle on x-axis and y-axis range %28-50 to 50%29 for both.

@Sagarg wrote:

Used SGPLOT polygon but it gives not whole rectangle form.

It is usually a good idea to include the code you attempted and describe what you need that the code isn't doing.

In the case of polygon the actual data step or file used is important.

An improperly shaped polygon would likely result from a missing vertex or an ID variable misaligned with the x and y coordinates.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Discussion stats
• 4 replies
• 474 views
• 4 likes
• 5 in conversation