0

I am running the library fantaxtic in R studio. I want to make a bar chart or something like that. However, in the legend I don't want any title in the legend and the category Other is located at the end the phyla names.

Is it posible?

This is my code:

library(fantaxtic)
    
sample_order<-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')
    
top_nested <- nested_top_taxa(physeq_Fungi, top_tax_level = 'Phylum', nested_tax_level = 'Order', n_top_taxa = 5, n_nested_taxa = 5)
    
test<-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'))

Thanks in advance

DEb!

I tried to solve it by myself but I have not reached any positive result yet.

I want to eliminate the label Order in the legend and the taxa called Other is at the end of the others taxa.

1 Answer 1

0

I am the author of the package. You can use regular ggplot2 to remove the legend title:

p + 
theme(legend.title=element_blank())

For more information on altering the legend, see the ggnested documentation.

Moving Other to the end of the legend is possible by following the Advanced Usage example, where you should set the Other position to Inf rather than 0:

...
psdf <- move_label(psdf = psdf,
                   col_name = top_level,
                   label = "Other",
                   pos = Inf)
...

However, note that this will also alter the order in the plot, placing Other at the bottom of the plot.

Not the answer you're looking for? Browse other questions tagged or ask your own question.