-1

I'm trying to make a stacked bar graph but I can't seem to get the protobacteria to group together. This is the code I used

ggplot(data = Bacteria, aes(x = bacteria$Location, y = bacteria$reads, fill = bacteria$Phylum.Division)) + 
  geom_bar(stat="identity")

Is there something I can add to my code? I've attached a picture of my graph currently.

enter image description here

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121
porterrose
  • 11
  • 1

1 Answers1

2

There are probably duplicate entries of protobacteria in your dataframe, but I cannot reproduce this in a simple example.

I noticed that in your code you use Bacteria and bacteria together. R is case sensitive and it could be you are using 2 dataframes for the plot. Also you can remove the bacteria$ part in the aes statement:

ggplot(data = bacteria, aes(x = Location, y = reads, fill = Phylum.Division)) + geom_bar(stat="identity")

If you want better help, please give a reproducible example of your problem.

Wietze314
  • 5,942
  • 2
  • 21
  • 40