2017-08-25 103 views
-1

我试图做一个堆积条形图,但我似乎无法得到protobacteria组合到一起。这是我使用的代码堆积柱形图分开我的变量

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

有什么我可以添加到我的代码?我现在附上了一张我的图片。

enter image description here

回答

2

可能有重复protobacteria的条目在你的数据帧,但我不能在一个简单的例子重现此。

我注意到,在你的代码中使用细菌和细菌一起。 R是大小写敏感的,也可能是您正在使用2个dataframes的情节。您也可以在AES语句删除bacteria$部分:

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

如果你想更好的帮助,请给你的问题的重复的例子。