【问题标题】:ggplot2 "unit" function not foundggplot2“单位”功能未找到
【发布时间】: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)
  • 是的,就是这样,写它作为答案,我会接受它

标签: r ggplot2


【解决方案1】:

unitgrid 包的一个函数。只需加载library(grid),它应该可以工作。

编辑:抱歉,没看到评论,已经回答了这个问题...

【讨论】:

    猜你喜欢
    • 2021-08-19
    • 1970-01-01
    • 2021-10-18
    • 2010-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多