2017-08-25 174 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") 

如果你想更好的幫助,請給你的問題的重複的例子。