1

这个问题是指并且需要(但可能不是?)facet_wrap_labellerRoland 在此处编写的函数:https ://stackoverflow.com/a/16964861/3275826

我的情况的MWE:

dput(test)
structure(list(V1 = c(0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 3.67, 3.73, 
3.79, 3.85, 3.91, 3.97), V2 = c(0.0291598, 3.40333, 1.3881, 0.15733, 
0.0200618, 0.00145373, 0.332262, 0.30233, 0.288497, 0.267876, 
0.264134, 0.227544), V3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
19L, 19L, 19L, 19L, 19L, 19L), .Label = c("Param0", "Param1", 
"Param2", "Param3", "Param4", "Param5", "Param6", "Param7", "Param8", 
"Param9", "Param10", "Param11", "Param12", "Param13", "Param14", 
"Param15", "Param16", "Param17", "Param18"), class = "factor")), .Names = c("V1", 
"V2", "V3"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 945L, 946L, 
947L, 948L, 949L, 950L), class = "data.frame")

dput(testLabels)
structure(c(2L, 1L), .Label = c("K[12:3]", "K[12]"), class = "factor")

## Will shows Param0 in the strip but this is modified by the facet_wrap_labeller
pp = ggplot(test, aes(x=test$V1)) + geom_ribbon(aes(ymin=0,ymax=test$V2), fill="blue",  alpha=0.2, colour="blue") + facet_wrap(~V3, scales="free", ncol=3)
facet_wrap_labeller(pp, testLabels)

问题:使用 facet_wrap 时,刻面条标签的操作并非易事。在我的情况下,情节显示 K[12:3] 等而不是 [12:3] 作为我想要的下标。

我喜欢 Roland 的函数,但我不知道如何适应标签下标不仅仅是整数的情况。可以在https://stackoverflow.com/a/6539953/3275826找到解决方案,但是我想知道如何调整上述功能,因为我有很多这样的实例。

在“语言计算”方面比我更有信心的人可以提供帮助,但也许我让问题过于复杂了?使用R 3.0.2ggplot2_0.9.3.1

4

0 回答 0