Desktop productivity for business analysts and programmers

How to avoid plots overlaying and make a visible differentiation in plots

Reply
Frequent Contributor
Posts: 87

How to avoid plots overlaying and make a visible differentiation in plots

Using the attached data, I am plotting the X, Y values w.r.t. Dates. I am using the following code:

 

proc sgplot  data=mydata;
series x=x y=y / group=Date break;
yaxis grid;
run;

And this is what plot looks like:

 

plot.png

 

Now question is...

 

in the above resulting plot I can not identify the 4 plots clearly.

 

Therefore, I want to do this:

  1. Between plots, can we add some common no. say something like 6 so that there occurs some visible difference.
  2. Thick lines with different colors (so that visually we can identify each)
Super User
Super User
Posts: 9,862

Re: How to avoid plots overlaying and make a visible differentiation in plots

Posted in reply to imanojkumar1

Hi,

 

Please post test data as a datastep in the body of the post, attached xlsx files are a security risk.  With regards to your questions:

1)

What you talk about is jittering.  Here are some examples:

http://blogs.sas.com/content/graphicallyspeaking/2013/07/10/make-better-graphs-with-sas-9-4/

http://blogs.sas.com/content/iml/2011/07/05/jittering-to-prevent-overplotting-in-statistical-graphic...

You could also manipulate your data, i.e. each group gets +6 added to the result, more than the previous group.  Do this in a datastep before the sgplot.

 

2) 

To set the size of the lines, you use 

lineattrs=(thickness=X)

Where x is the width.

Frequent Contributor
Posts: 87

Re: How to avoid plots overlaying and make a visible differentiation in plots

Hi RW9,
Thanks for raising the concerns. I can assure this file is virus checked before uploading.
Also, this data has some 5000 odds rows, so data step might not be a good option on this forum. And that's the reason why I had to upload the xlsx file (which is exported from SAS EG I work on).
Super User
Super User
Posts: 9,862

Re: How to avoid plots overlaying and make a visible differentiation in plots

Posted in reply to imanojkumar1

Its not concerns, its statutory company policy, and security sense for anyone.  If you need to post test data, do so as a datastep (to show structure) and only a few of the obsevations necessary to illustrate the problem.  You can do this by following this post:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

Super User
Posts: 10,852

Re: How to avoid plots overlaying and make a visible differentiation in plots

Posted in reply to imanojkumar1

proc sgpanel  data=mydata;
panelby date;
series x=x y=y /  break;
run;

Frequent Contributor
Posts: 87

Re: How to avoid plots overlaying and make a visible differentiation in plots

[ Edited ]

Hi KSharp, Thanks for your suggestion. I already tried it. Unfortunately, this way the outcome is in 4 panels. But what I want that all the 4 plots in one panel, as in my question above, but where Date=6Jul16, the plot should be shifted up on Y-axis by 6000 in each row.
So where:
Date=6Jul16 and MeaNo=1,
the new_Y= -40075+6000 = -34075
Date=6Jul16 and MeaNo=2,
the new_Y= -39875+6000 = -33875
and so forth.
I am thinking, this way we can see some shift in the plot and difference between two dates (29Jun and 6Jul).

And I tried this..

 

PROC SQL;
 create table mydata as 
 SELECT *,
 CASE
 WHEN Date="06JUL2016"d THEN (y+6000)
 ELSE y
 END AS Y_Plus_6K
 FROM mydata;
QUIT;

proc sgplot  data=mydata1;
series x=x y=Y_Plus_6K / group=Date transparency=0.6 LINEATTRS=(thickness=2) break;
yaxis grid;
run;

 

But this looks horrible. May be you could suggest me something better.
Thanks once again.

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