0

我在 R 中使用 plot_bar 函数来说明来自 phyloseq 类的一些数据。我想为我的情节添加一些不同的颜色,这里是 RColorBrewer 包中的配对调色板。由于某些原因,这些条最终仍然具有它们周围的默认颜色。在这里你可以看到它的样子:https : //imgur.com/a/VSBvwtk 有什么办法可以摆脱它们吗?

phylum.both.b <- plot_bar(both.b, fill="phylum") + 
  geom_bar(aes(color=phylum, fill=phylum), stat="identity")  + 
  scale_y_continuous(expand=c(0,0)) + 
  labs(x="", y="Relative abundance")  + 
  scale_fill_brewer(palette="Paired") +
  theme(axis.text.x=element_blank())  + 
  facet_wrap(~Type, scale="free_x", ncol=4) +
  facet_row(vars(Type), scales = 'free', space = 'free')
ggsave("PhylumBothBact.png", phylum.both.b, height=15, width=40, unit="cm")
4

1 回答 1

0

color = phylum在创建绘图时定义了颜色,但从未手动定义颜色,因此仍使用默认值。fill在条形图中用颜色填充条形并color勾勒出条形。

尝试添加scale_color_manual(values = NA)到您的情节中。或者,如果您希望大纲匹配,您可以使用scale_color_brewer(palette = "Paired")

于 2020-07-28T12:31:03.937 回答