Grouped Box Plots
Hi all,
Box plots have always been painful, but Igor 8's AppendBoxPlot and ModifyBoxPlot provide much needed relief. But I want to go further and generate grouped box plots. Anyone have some code to do this that I could use?
To get a visual of the plot I have in mind, see https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html
I noticed that Igor 9 doesn't seem to have this additional capability. But it seems like alot of the infrastructure is there. Maybe Igor could allow for the wave in the AppendBoxPlot to be a multidimensional wave, with every element in this new dimension be each of the group members? I couldn't find examples in the documentation for what I have in mind for this grouped box plot, but maybe the fine WM folks have it built in and I just haven't hit on the right command yet.
Thanks for any help.
Hi Donna,
I wrote a tool to help me make box plots. Take a look at this post to see if if it can help.
https://www.wavemetrics.com/forum/general/tool-handling-nominal-data-or…
Andy
March 15, 2021 at 06:42 pm - Permalink
Hi Donna,
I checked this works in Igor8. Make 2D waves with rows as data points, columns as groups. You need a wave for each sequence you want to plot. Make a box plot vs a text wave with the first one and then append the additional 2D waves. Like this:
•Make/O/N=(20,3) aaa=gnoise(1),bbb=gnoise(1.2)
// names of the groups
•Make/O/N=3/T labelW={"exp 1","exp 2","exp 3"}
// make boxplot
•Display;AppendBoxPlot aaa vs labelW
•AppendBoxPlot bbb vs labelW
// to show that the groups are different
•ModifyGraph rgb(aaa)=(65535,32768,32768)
•ModifyGraph rgb(bbb)=(16385,49025,65535)
•ModifyBoxPlot trace=aaa,markers={19,-1,19}
•ModifyBoxPlot trace=bbb,markers={19,-1,19}
March 16, 2021 at 12:27 am - Permalink
In reply to Hi Donna, I checked this… by sjr51
Thanks sjr51! That is just what I was looking for!
Donna
March 16, 2021 at 09:17 am - Permalink
To be clear, the picture you showed is a category plot with two sets of box plots. That is possible using Igor 8. It just falls out naturally if you make a box plot as a category plot, then add another box plot using the same horizontal axis/text wave as X wave.
What's new in Igor 9 beta is the ability to change the appearance of individual boxes within a single set of boxes.
March 16, 2021 at 09:55 am - Permalink
In reply to Thanks sjr51! That is just… by donna
Welp, I emailed a bit too soon. Your solution of using a text wave as the x axis wave does make the categories clear, but the native x axis for my data is not a 'category', but a number. In particular I want to create diel plots where the x axis indicates hour after midnight for 24 individual 'boxes' for category aaa and bbb. It is awkward and tedious for the x axis to display {"0:00","1:00", .. "23:00"), I would only need to display 6 or 8 of those labels and interpretation of each box plot is clear. In your example, if labelW was replaced by labelN={0,1,2} and you AppendBoxPlot aaa vs labelN;AppendBoxPlot bbb vs labelN these box plots lay on top of each other. If I just try to offset each category aaa and bbb, the size of the boxes are still too big and they overlap each other. So I am still stuck. Ideas?
March 16, 2021 at 10:18 am - Permalink
In reply to Welp, I emailed a bit too… by donna
Maybe I'm missing something but "hour after midnight" is 24 categories? I mean, you still have categories and can use a textwave rather than numeric wave. So you make a text wave with 24 rows as the labelW. Then add and append your box plots as I described. If you don't want all the labels showing you can just have "" for those?
Something like Make/O/N=24/T labelW=num2str(p) will give a wave with unit hours after midnight. You can edit the labelW in a table to get the plot to format the labels the way what you want.
March 16, 2021 at 10:53 am - Permalink
If you really, really want a numeric X axis, then the boxes sit like a data point at the X value specified. If you don't use an X wave, then you get 0, 1, 2, ... You could use an X wave with 0, 1, 2, 3, ... 23 for the first set and 0.5, 1.5, 2.5, ..., 23.5 for the second set of boxes. But I have to say that box plots are ideally suited for category plots, and the R graph gallery you linked to shows only category plots. Seems like categories that happen to be times of day is likely to be the path of least resistance, and makes a lot of sense in terms of the fact that you want boxes with identical times to set side-by-side.
March 16, 2021 at 12:40 pm - Permalink