我在 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/