我有重复的facet标题,我需要将它组合成一个标题,其中包含以下示例数据:
structure(list(Level1 = structure(c(1L, 1L, 1L, 1L, 1L), .Label =
"Repeated", class = "factor"), Level2 = structure(c(1L, 1L, 2L, 2L, 2L),
.Label = c("A", "B"), class = "factor"), Level3 = structure(1:5, .Label
= c("A", "B", "C", "D", "E"), class = "factor"), Value = c(6L, 2L, 3L,
4L, 0L)), .Names = c("Level1", "Level2", "Level3", "Value"), class =
"data.frame", row.names = c(NA, -5L))
我使用facet_wrap()创建了一个带ggplot2的条形图,并将列数设置为1:
ggplot(data=samp, aes(x=reorder(Level3, Value), y=Value)) +
geom_bar(stat="identity") +
coord_flip() +
ylab("Value") +
xlab("Level3") +
facet_wrap(~Level1 + Level2, scales = 'free_y', ncol = 1)
我需要显示Level3,Level2和Level1因子的嵌套,但不重复任何facet标题。这里重复了Level1因子方面标题。
我尝试按照以下帖子中的说明操作,但无法弄清楚如何自定义数据:Nested facets in ggplot2 spanning groups
感谢任何帮助。