【发布时间】:2015-05-09 19:52:41
【问题描述】:
我正在尝试更改我的 ggplot2 绘图的图例大小,但遇到了关于缺少函数的错误:
> xy <- data.frame(x=1:10, y=10:1, type = rep(LETTERS[1:2], each=5))
> plot <- ggplot(data = xy) + geom_point(aes(x = x, y = y, color=type))
> plot + theme(legend.key.width = unit(5, "cm"))
Error in theme(legend.key.width = unit(5, "cm")) :
could not find function "unit"
我错过了什么还是这是一个错误?我正在运行最新版本:
> getRversion()
[1] ‘3.2.0’
> packageVersion('ggplot2')
[1] ‘1.0.1’
【问题讨论】:
-
试试
library (grid) -
是的,就是这样,写它作为答案,我会接受它