在条形图中使用新调色板时删除 R 中的原始颜色轮廓

Removing the original color outline in R when using a new pallette in a barplot

我在 R 中使用 plot_bar 函数来说明来自 phyloseq class 的一些数据。我想在我的情节中添加一些不同的颜色,这里是 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")

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

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