[英]R: Align facet_grid() to the top of the grid
我正在努力嘗試在 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 的標簽與網格圖例的頂部對齊,如第二張圖片所示:
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.