R:ggplot2 - switch参数无法按预期工作

3

这是一个相对简单的问题。

根据:http://docs.ggplot2.org/current/facet_grid.html

注意:我已经尝试使用Ggplot2的CRAN和Github版本。

使用此代码,我应该期望得到以下图表:

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")

图表:

enter image description here

但我得到的类似图表,其中“条纹文本”不在“y轴”后面而是在轴之前:

enter image description here

我的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 
1个回答

6
+ theme(strip.placement = "outside")

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接