- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am trying to create side by side violin plots (with 2 plots representing percentages of 2 groups) , with a boxplot overlay (the boxplot within showing mean, IQR and confidence intervals). Although I've been able to create the violin plot on its own, I am not sure how to create the boxplot.
I have a dataset with a continuous variable (percentage) and binary variable (disease). My original code, for the violin plots only, is below:
proc sort
data = adherence
out=sorted;
by percentage;
run;
proc kde
data = sorted;
by disease;
univar percentage / plots=none out = percent_dens;
run;
data plot;
set percent_dens;
mirror=-density;
run;
proc sgpanel data=plot nocycleattrs;
panelby DisType / layout=columnlattice onepanel novarname noborder colheaderpos=bottom;
band y=value upper=density lower=mirror / fill outline;
rowaxis label="MY GRAPH" grid;
colaxis display=none;
run;
Is there any way to do this on SAS? At the very least, I would want to include more detail to my violin plot, such as mean, median, and IQR (similar to what a boxplot can tell us....but on the violin plot). Is this an alternate, more feasible solution?
I would really appreciate if someone could help me out with this problem. There does not seem to a wealth of knowledge on the internet, as the use of violin plots seems to be fairly new (?). Also, I am a novice at using SAS, so any comments or tips would be helpful!!
Many thanks!
Christina
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Chris,
Wow, thank you for the help! This definitely answers some questions I had re: including IQR and mean/median into my violin plot.
On the other hand, does anyone else know anything about overlaying boxplots over violin plots? If possible, that would be the most ideal for what I'm looking for...
Thank again!
Christina
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you really want to overlay, i.e. have the box plot on top of the violin plot? That might look messy. Might look cleaner to have a box plot below each violin plot.
Rick Wicklin has a post that uses GTL to generate a box plot below a histrogram. https://blogs.sas.com/content/iml/2013/05/08/three-panel-visualization.html Something like that might work.
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Quentin,
Unfortunately, I would ideally like to have the overlay becauase the violin plot, on its own, is a bit too simple for describing my data. However, you bring up a good point about creating the plots separately and presenting them together! I think that this will be a good alternative if I can't figure out how to show on top of each other.
Thanks!
Christina
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hello, can I learn about how you deal with this problem that create boxplot overlay on violin plot? I have the same question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@xinlong wrote:
hello, can I learn about how you deal with this problem that create boxplot overlay on violin plot? I have the same question.
On this forum we prefer that you start a new thread and when related to a previous one to provide a link the other thread(s) by copying the url and pasting in you question box.
That way we can tell where your responses to questions are different from the poster of the original question and readers don't get confused.
It is a good idea to include some example data in the form of a working data step and what you have so far. Many approaches to graphing rely on the content of a data file and we can't tell what may be needed with your data without an example. Best is also to include the code you have such as your violin plot as a starting point.
Also Boxplots have a LOT of options. Which features from the box plot do you need?