简体   繁体   中英

change colors in bar chart in r to other colors

I hopes you can assist me. I made a bar chart in R of 3 bars. Now the bars are in grey, and I want to change them to other colors, but even when I write this in the code, the colors remain Grey. Do you have any idea?

Thank you,

p<-ggplot(DATA.df, aes(x=sentiment)) +
  geom_bar(stat="count")+theme_minimal()+
  scale_fill_manual(values=c('red', 'purple', 'pink'))
p

It looks like the issue is because you are trying to use scale_fill_manual but don't have anything mapped to the fill aesthetic. Here is an example using the built-in iris dataset:

library(ggplot2)
p <- ggplot(iris, aes(x=Species, fill = Species)) +
  geom_bar(stat="count")+
  theme_minimal()+
  scale_fill_manual(values=c('red', 'purple', 'pink'))
p

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM