使用其中之一 stringr::str_pad() 要么 theme(legend.spacing.x = ...) 或两者
stringr::str_pad()
theme(legend.spacing.x = ...)
g <- ggplot(totDays, aes(group, total84, colour = group)) + geom_jitter(size = 1, width = 0.1) + # so points aren't overlaid, width controls how much jitter geom_point(stat = "summary", fun.y = "mean", shape = 3, size = 3, colour = "black") + # crosses for mean geom_boxplot(alpha = 0, width = 0.5, lwd = 1, size = 0.5) + scale_color_manual(values = c("#00AFBB", "#E7B800"), ### added labels = stringr::str_pad(c("Drug", "Placebo"), 10, "right")) + scale_y_continuous(breaks = seq(0,84,14), minor_breaks = seq(0, 84, 14)) + # changes minor break line coord_flip() + labs(y = "Score") + geom_hline(yintercept = c(groupDF$m), linetype = "dotted") + geom_segment(x = 2.38, xend = 2.38, y = groupDF$m[2] + .1, yend = groupDF$m[1] - .1, size = .7, arrow = arrow(end = "both", type = "open", length = unit(0.15, "cm")), colour = "#696969") + annotate("text", x = 2.46, y = mean(groupDF$m), label = paste0("italic(p) == ", 0.02), parse = T) + theme_bw() + theme(axis.title.y = element_blank(), axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.text.x = element_text(size = 13), axis.title.x = element_text(size = 13, face = "bold", margin = margin(t = 0, r = 0, b = 10, l = 0), vjust = -2), legend.title = element_blank(), legend.position = "top", ### added legend.spacing.x = unit(0.25, 'cm'), legend.spacing.y = unit(.1, "cm"), legend.box.spacing = unit(.1, "cm"), # adjusts distance of box from x-axis legend.key.size = unit(1, "cm"), legend.text = element_text(size = 13, face = "bold"), strip.text = element_text(size = 13, face = "bold"), panel.grid.major.y = element_blank(), panel.grid.major.x = element_line(size=.4, color="#F7F7F7"))
创建于2019-03-11由 代表包 (v0.2.1.9000)