gmteunisse / fantaxtic

Fantaxtic - Nested Bar Plots for Phyloseq Data
26 stars 3 forks source link

Bold legend titles fails when changing theme #15

Closed MjelleLab closed 1 year ago

MjelleLab commented 1 year ago

The setting theme_classic(), the headers within the legends (Actinobacteria, Firmicutes, ...) are not in bold anymore, but rather gets around the name. Suggestions on how to fix this?


plot_nested_bar(ps_obj = top_nested$ps_obj,
                relative_abundances = T,
                #sample_order = sample_order,
                palette = c(Bacteroidetes = "#de2d26", 
                            Firmicutes = "#a1d99b",
                            Fusobacteria ="#08306b"),
                merged_clr = "grey90",
                top_level = "Phylum",
                nested_level = "Genus") + 
  facet_wrap(~Group, scales="free_x",ncol=1) + 
  theme_classic(base_size = 6) + 
  theme(legend.key.size = unit(6,"points")) +
  theme(axis.text.x = element_text(angle=45, hjust=1))+
  guides(fill=guide_legend(ncol =1))
gmteunisse commented 1 year ago

Thanks for using fantaxtic! You can fix this issue by passing your theme_classic call to theme_nested(), as well as any named arguments for that function. For more information, see the documentation of ggnested and the function's documentation (help(theme_nested)).

plot_nested_bar(ps_obj = top_nested$ps_obj,
                relative_abundances = T,
                #sample_order = sample_order,
                palette = c(Bacteroidetes = "#de2d26", 
                            Firmicutes = "#a1d99b",
                            Fusobacteria ="#08306b"),
                merged_clr = "grey90",
                top_level = "Phylum",
                nested_level = "Genus") + 
  facet_wrap(~Group, scales="free_x",ncol=1) + 
  theme_nested(theme_classic, base_size = 6) + 
  theme(legend.key.size = unit(6,"points")) +
  theme(axis.text.x = element_text(angle=45, hjust=1))+
  guides(fill=guide_legend(ncol =1))