Open anne-urai opened 8 years ago
It's indeed something that could be nice, but the devil is in the details there. Currently, "significance stars" are available as indication of the whether the intercept and slope are different from zero when you use stat_glm() with option 'disp_fit',true … but that's it.
The problem is that beyond very simple tests with a couple of categories, any test is very likely be wrong as gramm has no knowledge about the underlying structure of the data/experiment. For example the stars that are currently given with stat_glm() are "wrong" from the moment you start plotting more than one category: depending on the situation, either there is no multiple test correction, or if one category is a grouping variable the proper thing to do is a mixed-effect model which is not what gramm does, etc. In gramm all computations within a category are done as if the other categories weren't there.
In that sense not putting stars is a matter of simplicity (for me: adding all these test possibilities would be a staggering amount of work) and responsibility (it forces users to make their own tests). My guess is that these are the same reasons ggplot2 doesn't have them. To go around this in R, some packages that do fits or tests will call ggplot2 to output their results, that way the packages kind of guarantee a correct output in ggplot2. Doing this in Matlab with fitglme or fitlme fit objects could be very nice and is something I have on my mind (you're welcome to try and make a great add-on for gramm!!).
Now reading your post, one thing that could be also good and not too risky is just including the function you link (or similar functionality) to gramm. It leaves the user responsible for his tests but allows to get closer to publication-ready figures within gramm. I'll try to see if I can find a nice way to implement that.
Thanks for the suggestion!
Thanks for your fast response! I completely agree that the user should decide which tests to apply, and test the appropriate assumptions. My main problem currently is that even if I've already done statistics, showing this in the gramm plot in an easy way is not straightforward (unless I'm overlooking a feature...)
Perhaps an easy way to make gramm compatible with significance stars, would be to allow for drawing labels after calling stat_summary, providing the x-y values and stars (or other text). I think that geom_label now only allows for labels that are defined at the level of each entry in the input?
geom_label is indeed used to associate each data point with a label. I'll look into how specific star+lines labels could be added in a nice generic way in gramm. Sigstar is pretty cool but does it in an incredibly hack-ish (but clever!) way which would probably mess up gramm quite a bit.
I just wanted to bump this in the hope that significance stars will be added sometime.
BTW great work, this looks amazing and I'm looking forward to using it for the paper I'm writing.
Significance stars would be a nice feature for stat_summary.
Hi~ o( ̄▽ ̄)ブ I want my solution to be helpful.
I already have statistical results, and I capture layer handles using findobj('Type', 'axes')
after using Gramm. Then, I annotate stars on the coordinates of the main plotting area with text(x, y, '*', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle')
.
This method works well for batch annotating significance stars. ੭ ˙ᗜ˙ )੭ The key is selecting the layer to plot, perhaps axes(3)
or axes(4)
, depending on the figure windows. Therefore, before batch annotation, consider capturing layer handles for a figure. (●'◡'●)
Hi @Fusenheizi thanks for the comment. Indeed for now there is no better option than to add stars after gramm is done. However you don't need to use findobj()
to find axes once gramm is done. The gramm objects contains the handles to the plotting axes (arranged in an array corresponding to what you get on the figure). If g
is your gramm object, you can simply use g.facet_axes_handles
to get the handles once g.draw()
has been called.
It would be fantastic if, together with stat_summary or some of the other stat functions, inferential statistics could be plotted. The easiest would be to automatically plot little stars (e.g. https://nl.mathworks.com/matlabcentral/fileexchange/39696-raacampbell-sigstar) depending on the outcome of a predefined test - most commonly a t-test against zero within each group of data, or paired tests between values of x (or even between columns).
I don't think it's a feature in the original R-ggplot2 - however, I think it would be extremely useful to generate plots that are even closer to publication-ready. Thanks for coding up this great project!