在ggplot2中缺少情节标题

时间:2012-09-25 15:01:09

标签: r ggplot2

如何在ggplot2中创建情节标题?我在制作一个愚蠢的语法错误吗?

ggplot2 docs表示实验室(title ='foo')应该有效,但我只能使用x='foo'y='foo'来使用labs()ggtitle()title()都没有工作。

这是一个例子。

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')

1 个答案:

答案 0 :(得分:1)

您可以在函数main中使用qplot参数:

qplot(x,y, data=xy.df, geom='point', color=x*y, main = "New Plot Title") + 
  labs(x='Some Data', 
       y='Some Other Data')

enter image description here