Data visualization with SAS programming

overlay jitter scatter plot on boxplot in sgplot

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

overlay jitter scatter plot on boxplot in sgplot

I want to add jitter scatter plot on my boxplot.  I used sgplot to produce my boxplot.  I found this post here http://blogs.sas.com/content/graphicallyspeaking/2012/05/07/unbox-your-box-plots/

The picture is exactly what I want but I wonder if I can produce it with sgplot.

 

Below is my sgplot code

 

proc sgplot data=box;
/* title "Plot of Hemoglobin A1c - baseline";*/
YAXIS label='Diastolic blood pressure' LABELATTRS=(SIZE= 8);
XAXIS label=' ' LABELATTRS=(SIZE= 8);
vbox result / datalabel=outid;
ods output SGPlot=boxlist;
run;


Accepted Solutions
Solution
‎08-22-2017 08:11 PM
SAS Super FREQ
Posts: 925

Re: overlay jitter scatter plot on boxplot in sgplot

If you have SAS 9.4, maintenance 1 or greater, you can do it like this:

 

proc sgplot data=sashelp.cars;
vbox weight / category=type;
scatter x=type y=weight / jitter;
run;

SGPlot2.png

View solution in original post


All Replies
Super User
Posts: 11,114

Re: overlay jitter scatter plot on boxplot in sgplot

If you search your documentation for SGPLOT and SGPANEL for "Plot Type Compatibility" you will find that in those procedures the only plots that can be used together with VBOX are Density, HBOX and Histogram.

 

The nature of the plot determines which other types share the "plot space".

 

It may be possible with an annotate dataset with SGPLOT but no promises.

 

OR sumarize your data and possibly use Polygon and lineparm or such along with scatter to simulate the VBOX portion.

 

Super User
Posts: 19,058

Re: overlay jitter scatter plot on boxplot in sgplot

Pretty sure this was asked and answered recently on here. Search through the forums. You may also be interested in the default plots from PROC UNIVARIATE, they do a good job of displaying the distribution of data.
Solution
‎08-22-2017 08:11 PM
SAS Super FREQ
Posts: 925

Re: overlay jitter scatter plot on boxplot in sgplot

If you have SAS 9.4, maintenance 1 or greater, you can do it like this:

 

proc sgplot data=sashelp.cars;
vbox weight / category=type;
scatter x=type y=weight / jitter;
run;

SGPlot2.png

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 331 views
  • 5 likes
  • 4 in conversation