这是一个简单的问题。
根据:http://docs.ggplot2.org/current/facet_grid.html
注意:我尝试过使用CRAN和Ggub2版本的Ggplot2。
使用此代码,我应该期待这个图:
data <- transform(mtcars,
am = factor(am, levels = 0:1, c("Automatic", "Manual")),
gear = factor(gear, levels = 3:5, labels = c("Three", "Four", "Five"))
)
p <- ggplot(data, aes(mpg, disp)) + geom_point()
p + facet_grid(am ~ gear, switch = "both")
图表:
但是我得到了一个类似的图形,其中“条纹文本”不在“y axi”之后但在axi之前:
我的sessionInfo():
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Spanish_Peru.1252
[2] LC_CTYPE=Spanish_Peru.1252
[3] LC_MONETARY=Spanish_Peru.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Spanish_Peru.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] dplyr_0.5.0 ggplot2_2.2.1.9000
loaded via a namespace (and not attached):
[1] Rcpp_0.12.9 assertthat_0.1 digest_0.6.12
[4] withr_1.0.2 grid_3.3.2 R6_2.2.0
[7] plyr_1.8.4 DBI_0.5-1 gtable_0.2.0
[10] magrittr_1.5 git2r_0.16.0 scales_0.4.1
[13] httr_1.2.1 stringi_1.1.2 reshape2_1.4.2
[16] lazyeval_0.2.0 curl_2.3 labeling_0.3
[19] devtools_1.12.0 tools_3.3.2 stringr_1.1.0
[22] munsell_0.4.3 colorspace_1.3-1 memoise_1.0.0
[25] knitr_1.15.1 tibble_1.2-15
答案 0 :(得分:6)
+ theme(strip.placement = "outside")