BookmarkSubscribeRSS Feed
CEB
Calcite | Level 5 CEB
Calcite | Level 5

Using gcontour to create a plot with grid lines showing, I get plots in which the grid lines appear in front of the contour lines. Since the grid lines are light gray and the contours are black, this visually looks like the contour lines have breaks in them. Depending on the shape of the contours, the pattern of breaks is quite obvious and distracting, and can even create a Moire effect. I have also tried href and vref lines, but they also break contour lines. Is there a way to put the grid (or ref) lines behind the contours?

I'm also using grid lines with gplot and i=join, in which case the grid appears behind the plotted curves and it looks fine.

Code example:

proc gcontour data=example;

plot y*x=z / nolegend autolabel levels=0 to 5 by 0.5 grid;

run;

Thank you!

2 REPLIES 2
GraphGuy
Meteorite | Level 14

One work-around would be to annotate the grid/reflines, using when='b' to draw them before/behind the rest of the graph...

data anno_grid;
when='b'; color='graydd';
do x_loop=0 to 10 by 2.5;
xsys='2'; ysys='1';
function='move'; x=x_loop; y=0; output;
function='draw'; y=100; output;
end;
do y_loop=0 to 7 by 1.75;
ysys='2'; xsys='1';
function='move'; y=y_loop; x=0; output;
function='draw'; x=100; output;
end;
run;

proc gcontour data=sashelp.lake anno=anno_grid;
plot length*width=depth / nolegend autolabel
  levels=-10 to 0 by 2;
run;

CEB
Calcite | Level 5 CEB
Calcite | Level 5

Yes, and it is probably worth doing if there is not an easier way. Thanks - it was kind of you to take the trouble to write it out, too.

I am going to wait a little while to see if somebody comes up with an easier way, but if not, I will annotate the graph. I was already wondering if I had to use annotation to solve another problem about uneven tick marks, which I will post in another thread.

Thank you!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1283 views
  • 3 likes
  • 2 in conversation