r - ggplot 标题不起作用?

标签 r ggplot2 title

我在 R 中使用 ggplot2 库并试图在我的 ggplot 上添加一个标题,但它告诉我 ggtitle 函数不存在!

这是我的代码:

p <- ggplot (data, aes(x, y)) +
  geom_point(shape= 21, fill= "blue", colour= "black", size=2) +
  xlab("X Value") + ylab("Y Value") +
  geom_smooth(method= "lm", se= FALSE,  colour= "red", formula=y ~ poly(x, 3, raw=TRUE)) +
  geom_errorbar(aes(ymin=y-SE, ymax=y+SE), width=.9)
p

我试过了,但没用:

    p <- ggplot (data, aes(x, y)) +
      geom_point(shape= 21, fill= "blue", colour= "black", size=2) +
      xlab("X Value") + ylab("Y Value") +
      geom_smooth(method= "lm", se= FALSE,  colour= "red", formula=y ~ poly(x, 3, raw=TRUE)) +
      geom_errorbar(aes(ymin=y-SE, ymax=y+SE), width=.9) + 
      ggtitle( "title")
    p

如有任何帮助,我们将不胜感激!

最佳答案

您可能正在使用 ggplot2 < 0.9.2。试试这个:

p + opts(title="Title text").

关于r - ggplot 标题不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19574379/

相关文章:

r - 将两个data.tables相乘,保留所有可能性

返回选定的函数参数

r - 如何按其中一行的子集的平均值对数据框进行排序?

javascript - 在折叠图标上设置标题

javascript - 如何使用javascript获取当前html页面标题

html - 为什么 html title 属性和 twitter bootstrap data-original-title 互斥?

r - 无法使用 rvest 抓取带有表单的网站

r - dcast 2 列

r - ggplot2 错误 - 'Discrete value supplied to continuous scale'

r - 使用 ggplot2 向具有多个 stat_bin 层的直方图添加图例