BookmarkSubscribeRSS Feed
22
Calcite | Level 5 22
Calcite | Level 5

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;

6 REPLIES 6
ballardw
Super User

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.

22
Calcite | Level 5 22
Calcite | Level 5

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
ballardw
Super User

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

22
Calcite | Level 5 22
Calcite | Level 5

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

ballardw
Super User

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.

22
Calcite | Level 5 22
Calcite | Level 5

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!

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1619 views
  • 0 likes
  • 2 in conversation