我正在 R studio 中运行 fantaxtic 库。我想绘制类似的条形图。但是,在图例中,我不希望图例中出现任何标题,并且“其他”类别位于门名称的末尾。
可以吗?
这是我的代码:
图书馆(梦幻般的)
样品订单<-c('Control.t0','Control.t30', 'Control.t60', 'LPSC.232.t30', 'LPSC.232.t60', 'APS.Control.t0', 'APS.Control.t30', 'APS.LPSC.232.t30','APS.Control.t60', 'APS.LPSC.232.t60')
顶部嵌套<- nested_top_taxa(physeq_Fungi, top_tax_level = 'Phylum', nested_tax_level = 'Order', n_top_taxa = 5, n_nested_taxa = 5)
测试<-plot_nested_bar(top_nested$ps_obj, top_level = "Phylum", nested_level = "Order", nested_merged_label = "Other Orders", palette = c('Ascomycota' = 'green' , 'Basidiomycota' = 'purple" , 'Cryptomycota' = "blue", 'LKM15' = "red", 'Mucoromycota' = "yellow")) + facet_wrap(~Oxidation, scales = "free_x") + theme(plot.title = element_text(hjust = 0.6, size = 12, face = "bold", color = 'black'), legend.title = element_text(color = 'black', face = "bold"), legend.key.size = unit(8, "points"), legend.position = 'bottom', axis.text.x = element_text(angle = 0, hjust = 0.5, color = 'black'), axis.text.y = element_text(color = 'black'), strip.text = element_text(face = "bold", color = 'black'))
提前致谢
DEb!
我尝试自己解决这个问题,但还没有取得任何积极的结果。
我想消除图例中的标签 Order ,并且名为 Other 的分类单元位于其他分类单元的末尾。
我是该包的作者。您可以使用常规 ggplot2 删除图例标题:
p +
theme(legend.title=element_blank())
有关更改图例的更多信息,请参阅 ggnested 文档。
可以按照高级使用示例将“其他”移动到图例的末尾,您应该将“其他”位置设置为
Inf
而不是0
:
...
psdf <- move_label(psdf = psdf,
col_name = top_level,
label = "Other",
pos = Inf)
...
但是,请注意,这也会改变图中的顺序,将“其他”放置在图的底部。