我正在使用ggplot来说明一组图的结果。几个月前,当我第一次制作我的数据时(以及ggplot的最新升级之前),我能够做到这一点:
然而,现在我必须重新制作重新提交的数据,现在我已经更新到最新版本的ggplot,这就是完全相同的代码所产生的:
供参考,这是我正在使用的代码
#################### Set ggplot theme
themebar = theme(axis.text.x = element_text(face="bold", color="black", size=rel(1), angle=0),
axis.title.x = element_text(size = rel(1.1), angle = 0, face="bold"),
axis.text.y = element_text(face="bold", color="black", size=rel(1), angle=0),
axis.title.y = element_text(size = rel(1.1), angle = 90, face="bold"),
panel.border = element_rect(linetype = "solid", colour = "black", fill=NA),
legend.text = element_text(size = rel(0.7), face = "bold", lineheight=0.8),
legend.position = "bottom",
legend.box = "vertical",
legend.background = element_rect(fill=NA, size=0.25, linetype="solid", colour ="black"),
legend.title = element_blank(),
panel.grid.major = element_line(colour="gray", linetype = "dotted"),
panel.background = element_rect(fill = NA),
strip.background = element_rect(fill = NA),
strip.text = element_text(size=rel(1), face="bold")) # , strip.text = element_blank()
## labeller
alt_sites = c(`Kolkata` = "A", `Delhi` = "B", `Dong Thap` = "C", `Kibera` = "D", `Lwak` = "E")
ggplot(dat_2ceac_main, aes(x=wtpdol, y=prob, group=Intervention, colour=factor(Intervention))) + #
geom_line(size=1) +
geom_vline(aes(xintercept = 0), size=0.75, linetype=c("dotted"), show.legend=F) +
geom_vline(aes(xintercept = vce), data=threshold, linetype=c("dashed"), show.legend=F) +
geom_vline(aes(xintercept = ce), data=threshold, linetype=c("dotdash"), show.legend=F) +
facet_grid(site~., switch="y", labeller=labeller(site=as_labeller(alt_sites))) +
themebar + theme(strip.text.y = element_text(angle = 180, vjust=1), strip.switch.pad.grid=) +
scale_colour_manual(values=Set0, labels=c("No intervention", "Routine")) + # scale_colour_hue(c=120,l=45) +
scale_x_continuous(limits=c(0, 20000), labels=comma) +
scale_y_continuous(limits=c(0, 1)) +
guides(colour = guide_legend(nrow = 1, byrow=F)) + # title = "Intervention", title.position = "top",
ylab("Probability Cost-Effective") +
xlab("Willingness-to-pay per \ndisability-adjusted life-year averted, I$")
答案 0 :(得分:1)
如果没有查看示例数据,很难调试,但请尝试将其添加到themebar
的末尾:
+ strip.placement = "outside"