ggplot:消失的轴线

时间:2016-03-14 19:51:00

标签: r graphics ggplot2

使用theme_classic()会返回预期格式的图表,但缺少轴线。

使用theme_bw(),之后添加轴线仍然不显示轴线。例如

qplot(input_data$trait1, input_data$trait2) + 
theme_bw() + 
theme(axis.line = element_line(colour = "black", size=10, linetype = 1))

检查theme_bw()看起来好像大小和线型需要从NULL变为某种东西。

$ axis.line            :List of 4
  ..$ colour  : chr "black"
  ..$ size    : NULL
  ..$ linetype: NULL
  ..$ lineend : NULL

我尝试使用轴线创建一个新主题,但它不被识别为命令:

theme_classic2 = theme_set (theme_classic())
theme_classic2 = theme_update(axis.line = element_line(colour = "black", size=1,
                                                   linetype = 1)

我有一种感觉,我可能不小心改变了一些默认设置。

请帮忙。这相当令人愤怒,更不用说相当尴尬了。

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tidyr_0.4.0   ggplot2_2.1.0

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6 scales_0.4.0     magrittr_1.5         R6_2.1.2         assertthat_0.1  
 [7] plyr_1.8.3       parallel_3.2.3   DBI_0.3.1        tools_3.2.3          gtable_0.2.0     dplyr_0.4.3     
[13] Rcpp_0.12.3      grid_3.2.3       munsell_0.4.3   

0 个答案:

没有答案