问题描述
我正在努力尝试在R中格式化绘图的facet_grid。这是我的代码的可复制示例,其中包含可从R(ToothGrowth)中的数据集获取的数据。
library(ggplot2)
df <- ToothGrowth
bp <- ggplot(df,aes(x=dose,y=len,group=dose)) +
geom_Boxplot(aes(fill=dose)) +
facet_grid(supp ~ .) +
theme_minimal(base_size = 16) +
theme(legend.position = "none",axis.title.x = element_blank(),axis.title.y = element_blank(),axis.ticks = element_blank(),panel.grid.major.x = element_line(size = 0.25,colour = "grey80"),strip.text = element_text(size = 22,face = "bold"))
bp
我想将facet_grid的标签与网格图例的顶部对齐,如第二幅图所示:
谢谢。