首页 文章

R3.1.1中的ggplot错误[重复]

提问于
浏览
-2

这个问题在这里已有答案:

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

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

    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文档 .

相关问题