so i have this data eight_gen_scatter:
pro = c("CONCOCT", "MetaBAT", "MaxBin", "MyCC")
MEGAHIT = c(3, 3, 3, 3)
RayMeta = c(3, 2, 1, 4)
SPAdes = c(3, 3, 2, 3)
Velvet = c(3, 3, 0, 2)
and i have the following code:
ggplot(eight_gen_scatter_melted,aes(x=variable, y=value, color=Programas)) +
geom_bar(stat="identity",position="dodge") +
scale_fill_discrete(name="variable", breaks=c(1, 2, 3, 4),
labels=c("CONCOCT", "MaxBin", "MetaBAT", "MyCC")) +
scale_y_continuous(limits = c(0, 8))
But somehow the bars are with colour grey and just the border is with different colors, how do i fill up the bars with the colours.
I'll be very grateful if you could give some help.
THis code below works perfectly for me. I don't understand why did you add "scale_fill_discrete()"? Do you want to change the order of items in the legend?
The legend will be added automatically since you set "fill= Programas". So you don't need extra code.
ggplot(df, aes(x = variable, y = value, fill= Programas)) + geom_bar(stat = "identity", position = "dodge")
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.