在 ggplot2 中使面标签水平

use*_*480 2 plot r facet ggplot2

我希望分面图右侧标签上的名称是水平的,这样它们就不会被切断。例如,它显示为北英格兰、东米德兰兹等。

图片在这里:

M--*_*M-- 5

您可以使用strip.text.y = element_text(angle = 0)旋转右侧的面条。我正在使用iris数据集来制作一个可重现的示例。

library(ggplot2)

    ggplot() +
      geom_line(data= iris, aes(x = Sepal.Length, y = Petal.Width, 
                                colour = Species), stat = "identity") +
      facet_wrap(Species ~ ., strip.position = "right", ncol = 1, scales = "free_y") +
      theme_bw() +
      theme(strip.text.y = element_text(angle = 0),
            legend.position = "none")
Run Code Online (Sandbox Code Playgroud)