missing plot title in ggplot2

Posted by Ben Mazzotta on Stack Overflow See other posts from Stack Overflow or by Ben Mazzotta
Published on 2012-09-25T15:01:08Z Indexed on 2012/09/25 15:37 UTC
Read the original article Hit count: 201

Filed under:
|

How can I create a plot title in ggplot2? Am I making a silly syntax error?

The ggplot2 docs indicate that labs(title = 'foo') should work, but I can only get the arguments x='foo' and y='foo' to work with labs(). Neither ggtitle() nor title() worked either.

Here is an example.

x <- rnorm(10,10,1)
y <- rnorm(10,20,2)
xy.df <- data.frame(x,y)
qplot(x,y, data=xy.df, geom='point', color=x*y) + 
  labs(title = "New Plot Title",
       x='Some Data', 
       y='Some Other Data')

© Stack Overflow or respective owner

Related posts about r

    Related posts about ggplot2