2016-01-22 97 views
-1

我想知道如何可以改变x值= 0,标记与所述图像中的横格线,在我的图表表示从+变化香港专业教育学院到-ive。我想有它标记为红色与相同厚度。谢谢GGPLOT2箱线图值0格颜色和线条类型

===基于注释

@Mtoto更新:我的道歉。这是脚本。

df.boxplot<- ggplot(melt(df[,c(2:7)]), aes(variable, value)) 
df.boxplot + 
    geom_boxplot(lwd=1.2)+ theme_economist() + scale_colour_economist()+ 
    scale_y_continuous(minor_breaks=seq(-5, 10, 0.5),name="Linear Measurements (mm)", breaks=seq(-5, 10, 1)) + 
    theme(axis.title.x = element_text(face="bold", colour="Black", size=20), 
     axis.text.x = element_text(face="bold", colour="Black", vjust=0.5, size=20)) + 
    scale_x_discrete(name="",labels=c("T0 A","T1 B","Δ AB","T0 C","T1 D","Δ CD")) + 
    theme(axis.title.y = element_text(face="bold", colour="Black", size=30,margin=margin(0,20,0,0)), 
     axis.text.y = element_text(angle=90, vjust=1, size=20)) + 
    theme(panel.grid.minor = element_line(colour="White",size=0.2))+ 
    theme(axis.ticks = element_blank())+ 
    ggtitle(" Title")+ 
    theme(plot.title = element_text(size=25,lineheight=2, hjust =0.5, vjust=0.5, margin = margin(20, 10, 20, 0))) 

我还想在前三个箱型图和后三个箱型图之间增加一个空白(一个x单位/级)。我尝试添加一列NA和使用降= FALSE,并没有奏效。

enter image description here

+1

例如请 – mtoto

+0

即使你更新后,这是不是[重复性(http://stackoverflow.com/q/5963269/2572423)。在你的例子中'df'是什么?提供一些示例数据,以便我们可以复制该问题。 – JasonAizkalns

回答

1

我想你想看看geom_hline - 我敢肯定,这是一个重复...数据和代码,没有图像的

library(ggplot2) 

df <- data.frame(x = gl(5, 25), 
       y = rnorm(125)) 

ggplot(df, aes(x, y)) + 
    geom_boxplot() + 
    geom_hline(aes(y_intercept = 0), color = "red") 

enter image description here