Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ggplot2:如何使用facet_wrap_labeller获得正确的下标_R_Ggplot2_Facet Wrap - Fatal编程技术网

ggplot2:如何使用facet_wrap_labeller获得正确的下标

ggplot2:如何使用facet_wrap_labeller获得正确的下标,r,ggplot2,facet-wrap,R,Ggplot2,Facet Wrap,这个问题是指罗兰在这里写的函数facet_wrap_labeller,需要但可能不需要: 我的情况是: 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,

这个问题是指罗兰在这里写的函数facet_wrap_labeller,需要但可能不需要:

我的情况是:

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)
问题:在使用镶嵌面包裹时,镶嵌面条标签的操作非常繁琐。在我的例子中,图中显示了K[12:3]等,而不是我想要的[12:3]作为下标

我喜欢罗兰的函数,但我不知道如何使它适应于标签下标不仅仅是整数的情况。 一个解决方案可以在找到,但是我想知道如何适应上述功能,因为我有很多这样的例子


在语言计算方面比我更有信心的人可能会有所帮助,但也许我把问题复杂化了?使用R 3.0.2和ggplot2_0.9.3.1.

您可以将罗兰函数与facet_wrap_labellerpp、expressionK[12]、K[12:3]一起使用,或者在函数editGrobmodgrob、label=parsetext=labels[ii]中对此进行更改,谢谢。如果你们中有人能写一个简短的答案,我会接受的。哪一个对你有用,nstjhp?我试图使用相同的函数,但它似乎没有修改标签。干杯。@meep实际上都为我工作。通过查看我的旧代码,我使用了baptiste的解决方案,因为我有很多这样的K[x:y]东西。