Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot title not working?

Tags:

r

ggplot2

title

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!

like image 621
Purrina Avatar asked Feb 27 '26 06:02

Purrina


1 Answers

You are probably using ggplot2 < 0.9.2. Try this instead:

p + opts(title="Title text").
like image 167
zero323 Avatar answered Mar 01 '26 00:03

zero323