我有一些代码,因为升级到最新的ggplot2版本后不再有效。自12月初以来它一直在外面,我想知道是否有其他人有同样的问题。
以下代码用于完美运行:
gLM1 <- ggplot(data = raw.data, aes(x = predict.lm1, y = (Sales_C-predict.lm1))) +
geom_point(alpha = I(0.75), colour = myPal[1]) +
geom_smooth(span = 0.75, degree = 1, size = 1.25, se = FALSE, colour = myPal[5]) +
labs(list(title = "Fitted vs Residuals", x = "Fitted Values", y = "Residuals")) +
theme_bw() + myGgTheme
gLM1
现在突然回来了:
错误:未知参数:度
如果我从geom_smooth中删除degree参数,它会再次起作用。 同样,此代码用于运行,现在失败:
gclus <- ggplot(data = raw.data, aes(x = oOrollingSD, y = OnTarget, colour = clusterGroup, size = Quota)) +
xlim(4.2, 11.8) +
geom_point(alpha = I(0.75)) +
geom_vline(x = 7.8, linetype = "dashed", colour = myPal[3]) +
scale_colour_manual(values = myPalContrasts[c(7,3,4)]) +
theme_bw() + myGgThemeSilentX
gclus
错误是
错误:未知参数:x
如果我删除了geom_vline
,它会再次起作用(我不能在这里删除x参数,因为这是使vline位置的原因!
直到昨天,所有这些代码都正常运行。在过去的几周里我准备了几十次报告。我读到了ggplot2的最新版本,并在昨天更新了这些错误。
我的ggplot2版本是2.0,我的所有其他会话信息都在下面。我不记得之前我的ggplot2版本:
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_Singapore.1252
[2] LC_CTYPE=English_Singapore.1252
[3] LC_MONETARY=English_Singapore.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_Singapore.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] dplyr_0.4.3 readr_0.1.1 stringr_1.0.0
[4] knitr_1.11 ggplot2_2.0.0 lattice_0.20-33
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 digest_0.6.8 assertthat_0.1
[4] R6_2.1.1 grid_3.2.2 plyr_1.8.3
[7] gtable_0.1.2 DBI_0.3.1 magrittr_1.5
[10] scales_0.3.0 highr_0.5.1 stringi_0.5-5
[13] lazyeval_0.1.10 curl_0.9.3 rmarkdown_0.8.1
[16] labeling_0.3 tools_3.2.2 munsell_0.4.2
[19] parallel_3.2.2 colorspace_1.2-6 htmltools_0.2.6
答案 0 :(得分:8)
来自文档,
1-使用method.args
将更多参数传递给建模函数
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_smooth(method = "loess", method.args=list(degree=2))
2-相关的审美是xintercept
ggplot(mtcars, aes(wt, mpg)) + geom_point() +
geom_vline(xintercept = 5)