Display of significance relationships in the ggplot2 histogram

Despite the fact that the main question that I am asking was considered in at least one previous post , the method described there did not work, and there was no proposed solution, it was discussed here .

For reference, I am trying to recreate the shape associated here using ggplot2in R.

A simplified version of the data frame used here is used:

 df <-data.frame(
  Related = c("Rel","Rel","Unrel","Unrel"),
  Integrated = c("Integ", "Unint", "Integ", "Unint"),
  Rate = c(11,8,6,4),
  SE = c(1.5,1.4,1.3,1.2))

In terms of bars, SE error bars, axes and general formatting, I essentially accomplished what I needed so far using the following (although please note that I process the x-axes labels and reports the p-value separately) :

dodge <- position_dodge(width = 0.9)
g1    <- ggplot(data = df, aes(x = interaction(Integrated, Related), y     = Rate, fill = interaction(Integrated, Related))) 
g1    <- g1 + layer(geom="bar", stat="identity", position = position_dodge())
g1    <- g1 + scale_fill_manual(values=c("#990000", "#CC6666", "#000099", "#9999CC"))
g1    <- g1 + guides(fill=FALSE)
g1    <- g1 + geom_errorbar(aes(ymax = Rate + SE, ymin = Rate - SE), position = dodge, width = 0.2) 
g1    <- g1 + coord_cartesian(ylim = c(0, 15))
g1    <- g1 + scale_y_continuous(breaks=seq(0, 14, 2))
g1    <- g1 + theme_classic()
g1    <- g1 + theme(text = element_text(size=20))
g1    <- g1 + ylab("Mismatch effect (%)")
g1    <- g1 + theme(axis.title.y=element_text(vjust=1.5))
g1    <- g1 + theme(plot.margin = unit(c(1, 1, 4, 1), "lines"),
                axis.title.x = element_blank(),
                axis.text.x = element_blank())

, / , . ( ), , .

:

 g1 + geom_path(x=c(1.5,1.5,3.5,3.5),y=c(13,14,14,13))+  annotate("text",x=2.5,y=15,label="*")

:

geom_path: . ?

(, ), df :

:

data2 <- data.frame(x = c(1.5, 1.5, 3.5, 3.5), y = c(13, 14, 14, 13))
g1 + geom_path(data = data2, aes(x = x, y = y))

-, :

:

(Integrated, Related): "Integrated"

, , . , , . .

+4
1

geom_path . , aes(group=1):

g1 + geom_path(aes(group=1), x=c(1.5,1.5,3.5,3.5), y=c(13,14,14,13)) +  
  annotate("text", x=2.5,y=14.4,label="*", size=8)

, object 'Integrated' not found, , , , . , :

data2 <- data.frame(x = c(1.5, 1.5, 3.5, 3.5), y = c(13, 14, 14, 13),
                    Integrated=NA, Related=NA)
g1 + geom_path(data = data2, aes(x = x, y = y))

, , , :

1) g1 , . + :

g1 <- ggplot(data = mis.eff, aes(x = interaction(Integrated, Related), 
             y = Rate, fill = interaction(Integrated, Related))) + 
       layer(geom="bar", stat="identity", position = position_dodge()) +
       scale_fill_manual(values=c("#990000", "#CC6666", "#000099", "#9999CC")) +
       ... etc.

2) y=15, y- , . 14.4. y, .

3) , . , , .

+2

All Articles