IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Add labels to boxplot dialogues #8242

Open rdstern opened 1 year ago

rdstern commented 1 year ago

This is the stack-overflow discussion on adding labels.

There are 6 suggestions and I wonder if the solution involving stat_summary is one we could use?

It would apply to both the general and the climatic boxplot dialogue. I assume we would (I assume) also add the link to geom_text into the Plot Options.

@Wezziebanda will provide details including providing the R-code quickly and then maybe @MeSophie could attack?

rdstern commented 1 year ago

On layout, I am keen that the dialogue does not need to become longer. So I suggest a) Move the Horizontal Plot option to the right,instead of the (disabled) swap parameters option. Put it there instead - as we have never done the work to enable that option. b) Add another option, called Label Outliers below the Add Points option. Details will be given by @wezziebanda. c) I assume it will only use geom_text? If so, also add geom_text into the Plot Options pull down. d) The R-code and an example will be given below.

WezzieBanda commented 1 year ago

@rdstern I used the survey data from R-instat library

da11<-read.csv ("C:/Users/grace/Downloads/survey.csv")

library(ggplot2)

ggplot(da11, aes(x = factor(village), y = yield, fill = factor(village))) + geom_boxplot() + stat_summary( aes(label = round(stat(y), 1)), geom = "text", fun.y = function(y) { o <- boxplot.stats(y)$out; if(length(o) == 0) NA else o }, hjust = -1 )

Labels

rdstern commented 1 year ago

@WezzieBanda that's great. Now can you do the same boxplot (without the labels of course) in R-Instat. Then press To Script to gwet the script, and add the stat_summary in the script file to get the same result.

Could you also try without the script, but using the Describe > General dialogue which allows you to build up a graph layer-by-layer. Could this be used to start with the boxplot and then add the summary layer?

(This sort of stuff would all have been soooo much easier to discuss when I had the time and we were together in Malawi!)

WezzieBanda commented 1 year ago

@rdstern I tried using the first option and it I got the same results. outlier1

I am now trying out the second option.