R3.1.1中的ggplot错误

时间:2014-07-23 06:04:17

标签: r ggplot2

我尝试使用Windows 8中R3.1.1中的ggplot在R中绘制一个简单的条形图。这是一个代码段:

ggplot(sent_df, aes(x=emotion))
+ geom_bar(aes(y=..count.., fill=emotion))
+ scale_fill_brewer(palette="Dark2")
+ labs(x="emotion categories", y="number of comments")
+ opts(title = "classification by emotion", plot.title = theme_text(size=12)) 

sent_df数据框,但收到错误:

  

错误:使用'主题'代替。 (已解散;最后一次在0.9.1版本中使用)"

1 个答案:

答案 0 :(得分:0)

opts不再使用了。相反,你必须使用theme试试这个

    ggplot(sent_df, aes(x=emotion)) + geom_bar(aes(y=..count.., fill=emotion)) + 
scale_fill_brewer(palette="Dark2") + labs(x="emotion categories", y="number of comments",
title = "classification by emotion") + theme(plot.title = element_text(size=12))

有关详细信息,请查看ggplot2文档。