ggplot2:添加用于 facet_grid 的变量名称

ggplot2: Add name of variable used for facet_grid

require(ggplot2)
ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(vs+gear ~ cyl+am) 

我想在此图上添加用于 facet_grid 的 4 个变量的名称。我想最好的方法是在角落添加变量名称,并用一个小箭头指向行或列。我正在考虑为此目的使用 annotation_customtextGrob,但未能在图表上打印任何内容。

是这样的吗?

ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(vs+gear ~ cyl+am,labeller = labeller(.rows = label_both, .cols = label_both))

您也可以使用如下语法:

labeller = label_bquote("Gear"==.(gear))