ggplot2:position_dodge不起作用

时间:2017-03-16 21:08:17

标签: r ggplot2

我无法让position_dodge工作以在栏之间添加空格。在时间搜索之后,我无法获得任何我在网上找到的解决方案。

编辑:这不是一个重复的问题。那种方法是我无法开展工作的方法。另一张海报也使用了不同的命令来显示它们的条形图,并且使用链接中建议的方法也不起作用。

以下是代码:

    plot3 <- ggplot(PTX, aes(x=Group, y=Percent.Baseline, group = Group)) +
stat_summary(fun.data="mean_cl_normal", geom = "errorbar", position = position_dodge(width = 10), width = 0.3, size = 1.2) +
stat_summary(fun.y="mean", geom="bar",fill = "white", color = "black", position_dodge(width = 10), size = 2) +
geom_point(data = PTX, name = "Estrous Cycle", aes(shape = PTX$Estrous.Cycle, color = PTX$Estrous.Cycle), 
         alpha = 1, size = 10.4, stroke = 3, show.legend=TRUE) +
scale_shape_manual(name = "Estrous Cycle", 
                 values=c(0, 1, 2), 
                 labels=c("Proestrous", "Estrous", "Diestrous")) +
scale_x_discrete(limits=c("HC", "ES", "IS")) +
scale_y_continuous(breaks=c(40,60,80,100,120)) +
coord_cartesian(ylim=c(43.8,120)) + 
scale_colour_manual(name = "Estrous Cycle",
                  labels = c("Proestrous", "Estrous", "Diestrous"),
                  values = c("navyblue", "darkgreen", "darkred")) +   
theme(panel.border = element_blank(),
    legend.key = element_rect(fill = NA, colour = NA, size = 0.25),
    axis.line = element_line(size = 2.5, linetype = "solid",
                             colour = "black"),
    panel.background = element_rect(fill = "transparent", color="NA"),
    axis.text.x = element_text(colour="grey20",size=24,hjust=.5,vjust=.5,face="bold"),
    axis.text.y = element_text(colour="grey20",size=24,hjust=1,vjust=0,face="bold"),  
    axis.title.x=element_blank(),
    axis.title.y=element_text(face="bold", size=40, color = "black"),
    axis.ticks.y = element_blank(),
    legend.key.height=unit(3.2, "line"),
    legend.key.width=unit(3.2, "line"),
    legend.title=element_text(size=21), 
    legend.text=element_text(size=21))

plotfinal <- plot3 + ylab("% Baseline")
plotfinal

现在情节如下:

enter image description here

0 个答案:

没有答案