The SAS Output Delivery System and reporting techniques

Proc GPLOT Broken Curves

Reply
Occasional Contributor 22
Occasional Contributor
Posts: 8

Proc GPLOT Broken Curves

[ Edited ]

Hi all,

 

I'm trying to create a normal X,Y plot using proc gplot and spline as interpoation. I found in more than one case that the generated curves are some how broken (not fully connected) which should not be the case. I also changed spline (interpol = SMn) and same thing occurs. I attached the dataset which includes the data as well as a PDF file that includes the generated (broken) curves. Please have a look to both Red and Green curves as they're not fully connected. Appreciate your assistance.

regards 

 

Code:

 

title ' ';
goptions reset=symbol;
PROC GPLOT DATA= MyData;
symbol1 interpol=JOIN color=blue line=1 width=3;
symbol2 interpol=SPLINE color=Red line=1 width=3;
symbol3 interpol=SPLINE color=Green line=1 width=3;
axis1 order=(0 to 1 by 0.1) offset=(2,2) label= ('X-Axis');
axis2 order=(0 to 1 by 0.1) offset=(2,2) label= ('Y-Axis');
legend1 value= ('Blue Curve' 'Red Curve' 'Green Curve');
plot (Blue_Curve Red_Curve Green_Curve)*(Blue_Curve) /
overlay legend= LEGEND1 autohref haxis=axis1 hminor=1 vaxis=axis2 vminor=1;
run;

Super User
Posts: 11,134

Re: Proc GPLOT Broken Curves

I didn't open the data but the chart indicates it is very likely that the data for you Y values exceeds 1. Since your Y axis limits the upper value to 1 any value above that is truncated from the display.

Occasional Contributor 22
Occasional Contributor
Posts: 8

Re: Proc GPLOT Broken Curves

Unfortunately, this is not the case.Here is the data in case you were unable to open it:

 

Green_curve Blue_Curve Red_Curve
0.00 0.00 0.00
0.43 0.01 1.00
0.43 0.02 1.00
0.43 0.03 1.00
0.43 0.05 1.00
0.57 0.07 1.00
0.57 0.09 1.00
0.57 0.13 1.00
0.57 0.18 1.00
0.86 0.24 1.00
0.86 0.30 1.00
0.86 0.36 1.00
0.86 0.42 1.00
1.00 0.53 1.00
1.00 0.68 1.00
1.00 0.87 1.00
1.00 1.00 1.00
1.00 1.00 1.00
Super User
Posts: 11,134

Re: Proc GPLOT Broken Curves

SPLINE creates values outside of the range. change the y axis to 0 to 1.1 by .1 and you'll see that.

Occasional Contributor 22
Occasional Contributor
Posts: 8

Re: Proc GPLOT Broken Curves

[ Edited ]

You're absolutely right! This is my bad! I should have thought about that!

 

Anyhow, do you know if there is a way to define the range in axis statement (order=) automatically without any manually intervention? Therefore, SAS checks the highest and lowest values SPLINE would generate and sets them automatically?

 

Regards

Super User
Posts: 11,134

Re: Proc GPLOT Broken Curves

Since spline generates curves outside the data and if the data is obnoxious enough might be quite variable from the actual input data range I would fall back on why I am attempting to control the y axis appearance at all.

 

If I am just trying to make a "clean" appearing axis then possibly I would consider something that controls the number of tick marks like Major = 10 and Minor=none and let SAS pick appropriate values.

 

If I am trying to provide consistent axis for multiple graphs then either  set the range large enough for the largest graph or possibly UNIFORM would work if you make all the graphs in the same pass through GPLOT.

 

Another quite different approach would be to calculate the values to be plotted (not a trivial exercise), determine the max and min y from that data and use that to set likely max/min value for an axis statement.

 

Or possibly consider a different smoothing option but some of those will have the same issue. Interpol = SMnn and experiment with values of nn between 01 and 99 to see which you like. This I believe is less likey to not exceed the data with largish values of nn, but no promises.

Occasional Contributor 22
Occasional Contributor
Posts: 8

Re: Proc GPLOT Broken Curves

[ Edited ]

Hi ,

 

Sorry for the late response.

 

I tried not to constrol the appearance of Y-axis but felt in the same issue. I removed the (order=) keyword from axis statement. The graph gave a range of (0-1) for each axis (X and Y) which I think is taken from the data points. Hence, once gain, SPLINE generated out of range (relative to data points) points whihc caused the curve to break in more than one place on the edges!

 

 

Ask a Question
Discussion stats
  • 6 replies
  • 744 views
  • 0 likes
  • 2 in conversation