Geom_line(data = arc.df, aes(Group+1, Value+5.5), lty = 2) + P + geom_text(data = label.df, label = "*") + To add the arcs that indicate a subgroup comparison, I computed parametric coordinates of a half circle and added them connected with geom_line. P + geom_text(data = label.df, label = "***") Geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5)Īdding asterisks above a column is easy, as baptiste already mentioned. Theme_bw() + theme(id = element_blank()) + Scale_fill_manual(values = c("grey80", "grey20"))įull documentation of the package is available at CRAN.įirst, I created some dummy data and a barplot which can be modified as we wish. To create a more advanced plot similar to the one shown by Jens Tierling, you can do: dat <- ame(Group = c("S1", "S1", "S2", "S2"), Geom_signif(comparisons = list(c("versicolor", "virginica")), Ggplot(iris, aes(x=Species, y=Sepal.Length)) + Instead of tediously adding the geom_line and geom_text to your plot you just add a single layer geom_signif: library(ggplot2) But I recently created a ggplot-extension that simplifies the whole process of adding significance bars: ggsignif Stat_boxplot(geom ='errorbar', width = 0.I know that this is an old question and the answer by Jens Tierling already provides one solution for the problem. library("mosaic") # For favstats()īoxplot_Tukey_upper <- max(df) Note this isn't the exact code I used to produce the image above but it gets the point over. Lower whisker = min(x) = 35 (where x is the data used to create the boxplot, outlier is at x = 27). For example, here is a plot drawn using geom_boxplot where I've added a dashed line at the value Q1 - 1.5*IQR: However, range=0 is a special case - it's equivalent to "range=infinity"Īs highlighted by in a comment, ggplot doesn't draw the whiskers at the upper/lower quartile plus/minus 1.5 times the IQR. > boxplot(x, range=0, main="range=0")#The same as range="Very big number"Īs we decrease range from 1.7 to 1.5 we reduce the length of the whisker. Have a look at `?quantile for the description of the nine different methods.Ĭonsider the following example > set.seed(1)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |