david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
106 stars 11 forks source link

comp_barplot reduce/remove space between axes and bars #166

Closed greboul closed 5 months ago

greboul commented 5 months ago

Hi,

I have been trying to reduce the space between axes and plot and I just can't figure it out.

It seems that there is some space created by comp_barplot like shown in example "p1" on the function wiki page. image

Is there a way to reduce such spacing between bars and axes?

Thanks, Guillaume

david-barnett commented 5 months ago

add expand = FALSE to the coord_flip() or to coord_cartesian() if not flipped

library(microViz)
#> microViz version 0.12.3 - Copyright (C) 2021-2024 David Barnett
#> ! Website: https://david-barnett.github.io/microViz
#> ✔ Useful?  For citation details, run: `citation("microViz")`
#> ✖ Silence? `suppressPackageStartupMessages(library(microViz))`
library(ggplot2)
data(dietswap, package = "microbiome")

dietswap %>%
  ps_filter(timepoint == 1) %>%
  comp_barplot(tax_level = "Family", n_taxa = 8) + 
  coord_flip(expand = FALSE)

Created on 2024-06-13 with reprex v2.1.0