# y.include.zero: logical. Does y.lim range include 0? Ignored if y.log is "log2" or "log10"
# y.top.extra.margin: single proportion (between 0 and 1) indicating if extra margins must be added to y.lim. If different from 0, add the range of the axis multiplied by y.top.extra.margin (e.g., abs(y.lim[2] - y.lim[1]) * y.top.extra.margin) to the top of y-axis
# y.bottom.extra.margin: idem as y.top.extra.margin but to the bottom of y-axis
# stat.disp: add the median number above the corresponding box. Either NULL (no number shown), "top" (at the top of the plot region) or "above" (above each box)
# stat.disp.mean: logical. Display mean numbers instead of median numbers? Ignored if stat.disp is NULL
# stat.size: numeric value of the stat font size in mm. Ignored if stat.disp is NULL
# stat.dist: numeric value of the stat distance in percentage of the y-axis range (stat.dist = 5 means move the number displayed at 5% of the y-axis range). Ignored if stat.disp is NULL or "top"
# stat.pos: add the median number above the corresponding box. Either NULL (no number shown), "top" (at the top of the plot region) or "above" (above each box)
# stat.mean: logical. Display mean numbers instead of median numbers? Ignored if stat.pos is NULL
# stat.size: numeric value of the stat font size in mm. Ignored if stat.pos is NULL
# stat.dist: numeric value of the stat distance in percentage of the y-axis range (stat.dist = 5 means move the number displayed at 5% of the y-axis range). Ignored if stat.pos is NULL or "top"
# stat.angle: integer value of the angle of stat, using the same rules as in ggplot2. Positive values for counterclockwise rotation: 0 for horizontal, 90 for vertical, 180 for upside down etc. Negative values for clockwise rotation: 0 for horizontal, -90 for vertical, -180 for upside down etc.
# vertical: logical. Vertical boxes? WARNING: will be automatically set to TRUE if y.log argument is other than "no". Indeed, not possible to have horizontal boxes with a log axis, due to a bug in ggplot2 (see https://github.com/tidyverse/ggplot2/issues/881)
# text.size: numeric value of the font size of the (1) axis numbers, (2) axis labels and (3) texts in the graphic legend (in mm)
...
...
@@ -9273,7 +9273,7 @@ lib.path = NULL
# $sup.whisker.edge: coordinates of top whisker edges (x and xend)
# $inf.whisker.edge: coordinates of bottom whisker edges(x and xend)
# $mean: diamond mean coordinates (only if box.mean argument is TRUE)
# $stat.display: coordinates of stat numbers (only if stat.disp argument is not NULL)
# $stat.pos: coordinates of stat numbers (only if stat.pos argument is not NULL)
# y.second.tick.positions: coordinates of secondary ticks (only if y.second.tick.nb argument is non-NULL or if y.log argument is different from "no")
# y.second.tick.values: values of secondary ticks. NULL except if y.second.tick.nb argument is non-NULL or if y.log argument is different from "no")
# $panel: the variable names used for the panels (NULL if no panels). WARNING: NA can be present according to ggplot2 upgrade to v3.3.0
stop(paste0("\n\n================\n\n", tempo.cat, "\n\n================\n\n", ifelse(is.null(warn), "", paste0("IN ADDITION\nWARNING", ifelse(warn.count > 1, "S", ""), ":\n\n", warn))), call. = FALSE) # == in stop() to be able to add several messages between ==
}
if( ! is.null(stat.disp)){
if( ! is.null(stat.pos)){
stat.just <- fun_gg_just(
angle = stat.angle,
pos = ifelse(
vertical == TRUE,
ifelse(stat.disp == "top", "bottom", "top"), # "bottom" because we want justification for text that are below the ref point which is the top of the graph. The opposite for "above"
ifelse(stat.disp == "top", "left", "right") # "left" because we want justification for text that are on the left of the ref point which is the right border of the graph. The opposite for "above"
ifelse(stat.pos == "top", "bottom", "top"), # "bottom" because we want justification for text that are below the ref point which is the top of the graph. The opposite for "above"
ifelse(stat.pos == "top", "left", "right") # "left" because we want justification for text that are on the left of the ref point which is the right border of the graph. The opposite for "above"
box.coord <- tempo.graph.info$data[[2]] # to have the summary statistics of the plot. Contrary to ini.box.plot, now integrates ylim Here because can be required for stat.disp when just box are plotted
box.coord <- tempo.graph.info$data[[2]] # to have the summary statistics of the plot. Contrary to ini.box.plot, now integrates ylim Here because can be required for stat.pos when just box are plotted
box.coord$x <- as.numeric(box.coord$x) # because x is of special class that block comparison of values using identical
box.coord$PANEL <- as.numeric(box.coord$PANEL) # because numbers as levels. But may be a problem is facet are reordered ?
tempo.stat <- data.frame(stat, Y = y.lim[2], stringsAsFactors = TRUE) # I had to create a data frame for geom_tex() so that facet is taken into account, (ggplot2::annotate() does not deal with facet because no data and mapping arguments). Of note, facet.categ is in tempo.stat, via tempo.mean, via dot.coord
)) # stat$X used here because identical to stat.nolog but has the X. WARNING: no need of order() for labels because box.coord$x set the order. For justification, see https://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot
coord.names <- c(coord.names, "stat.display")
}else if(stat.disp == "above"){
coord.names <- c(coord.names, "stat.pos")
}else if(stat.pos == "above"){
# stat coordinates
if( ! is.null(dot.color)){ # for text just above max dot
if(dot.tidy == FALSE){
...
...
@@ -11090,7 +11090,7 @@ stringsAsFactors = TRUE
# end stat coordinates
# stat display
# performed twice: first for y values >=0, then y values < 0, because only a single value allowed for hjust anf vjust
if(stat.disp.mean == FALSE){
if(stat.mean == FALSE){
tempo.center.ref <- "middle"
}else{
tempo.center.ref <- "MEAN"
...
...
@@ -11126,7 +11126,7 @@ angle = stat.angle,
hjust = stat.just$hjust,
vjust = stat.just$vjust
)) # WARNING: no need of order() for labels because box.coord$x set the order