Reputation: 175
I'm using the ggplot2 library in R and trying to put a title on my ggplot but it's telling me the ggtitle function doesn't exist!
This is my code:
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
I tried this but it isn't working:
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
Any help would be appreciated!
Upvotes: 3
Views: 7451
Reputation: 330413
You are probably using ggplot2 < 0.9.2. Try this instead:
p + opts(title="Title text").
Upvotes: 4