Data visualization with SAS programming

gcontour grid lines in front of contour lines

Reply
Occasional Contributor CEB
Occasional Contributor
Posts: 6

gcontour grid lines in front of contour lines

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!

SAS Employee
Posts: 967

gcontour grid lines in front of contour lines

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;

Occasional Contributor CEB
Occasional Contributor
Posts: 6

gcontour grid lines in front of contour lines

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!

Ask a Question
Discussion stats
  • 2 replies
  • 215 views
  • 3 likes
  • 2 in conversation