更新将问题发布到ggplot2 GitHub后,问题是R不允许图形设备中的制表符。
我正在尝试使用自定义贴标机标记我的情节的方面。我的标签文本包含\ t和\ n。 \ n字符正确呈现,但\ t产生正方形。
tabLabeller <- function(variable, value) {
return(paste0(as.character(value), 'Tab\tneeded Newline\nneeded'))
}
ggplot(mtcars, aes(x = cyl, y = mpg)) +
geom_point() +
facet_grid(~carb, labeller = tabLabeller)
这是情节:
会话信息是:
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.1
loaded via a namespace (and not attached):
[1] labeling_0.3 MASS_7.3-40 colorspace_1.2-6 scales_0.2.4 magrittr_1.5 plyr_1.8.2
[7] tools_3.2.0 gtable_0.1.2 reshape2_1.4.1 Rcpp_0.11.5 stringi_0.4-1 grid_3.2.0
[13] stringr_1.0.0 digest_0.6.8 proto_0.3-10 munsell_0.4.2