I would like to add significance labels following out of post-hoc analysis to box-and-whiskerplots from the function bwplot
from the lattice
package in R. I have read the ggplot2
-based solution in Posthoc labels on anova boxplot in R however this does not show a solution within the lattice
framework. Is there anyone here that has tried this before and could give me some pointers? If there is some way to derive the positions from a bwplot object (as suggested for a regular boxplot object in this article in the R mailing list ) I am guessing I should be looking in that direction? Thanks in advance!
Kind regards,
FM
If you are constructing your plot using interactive commands or a script of several commands, you can always manually add text using grid.text
because both lattice
and ggplot2
use grid
graphics under the hood. So check out this link (because ?grid.text
doesn't lead to the page). You'll want to watch your units and you may need to do upViewport(0)
to get to the root viewport (depending upon the details of your plotting steps).
I'm not sure where you wanted your labels, but here's an alternative using panel.text
.
dd <- data.frame(
x = runif(120),
ind = LETTERS[1:6]
)
library(lattice)
bwplot(ind ~ x, data = dd,
panel = function(x, y, ...) {
panel.bwplot(x, y, ...)
panel.text(x = tapply(x, y, median), y, pos = 2, offset = 1,
labels = c("*", "**", "", "", "ns", "***"), ...)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.