Data visualization with SAS programming

Controlling which plot lines are on top in a x*y=z graph

Reply
Regular Contributor
Posts: 179

Controlling which plot lines are on top in a x*y=z graph


Hi,

I'm sure this has been answered before but I'm not even sure what to search on.  When you have a graph displaying multiple lines (say sales by month and year, with the months along the x axis and each line on the graph representing a year), how do you control which line is 'on top'?

It would be nice to see the most recent year on the top if the data is close from one year to the next.

The graph in question uses spline smoothing in a set of SYMBOLn statements with different symbols (star, triangle, etc.) to represent the data points.  Currently some 2012 month points are buried by prior year points.  These are displayed as html graphs so hovering over the month in question returns the prior year value.

Thanks!

--Ben

Super User
Posts: 11,134

Re: Controlling which plot lines are on top in a x*y=z graph

It has been awhile since I played with this but I think it has to do with the order the SYMBOL statements are associated with values. Have you tried sorting the data by year (or Z in general). Or sometines sort by the FORMATTED value of Z.

IIRC if my first data point were associated with 2012 then it gets the Symbol1 statment and if the next record is 2010 it gets Symbol2. Then SAS displays them in symbol order.


Regular Contributor
Posts: 179

Re: Controlling which plot lines are on top in a x*y=z graph

Hi,

Thanks for taking a stab at it.  I have tried re-ordering the data and the Symbol(n) statements with no change in the graph.  May need to open a ticket with the Graph folks.

--Ben

SAS Employee
Posts: 980

Re: Controlling which plot lines are on top in a x*y=z graph

Typically, when I want to make sure a certain line is "in front" of the others, I re-arrange my data so that instead of using "plot y*x=z" I can use "plot y1*x=symbol-num y2*x=symbol-num y3*x=symbol-num".  And the lines are drawn in the order specified (the last one is drawn last, and is "in front").

Here's an example with exaggerated/thick lines to demonstrate (note that the symbol2 red line is on top):

symbol1 value=none interpol=join width=7 color=blue;
symbol2 value=none interpol=join width=7 color=red;
symbol3 value=none interpol=join width=7 color=pink;

proc gplot data=sashelp.stocks (where=(stock='IBM'));
plot
low*date=1
high*date=3
close*date=2
/ overlay;
run;

Regular Contributor
Posts: 179

Re: Controlling which plot lines are on top in a x*y=z graph

Oh!  I hadn't thought of using the overlay facility.  Good idea!  I'll give that a shot.

Thanks!

--Ben

Ask a Question
Discussion stats
  • 4 replies
  • 236 views
  • 0 likes
  • 3 in conversation