-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove x-axis labels with independent = "x" if they are identical #155
Comments
Hi there, thanks for the report! Could you give a minimal reprocible example? At the time of writing, I'm too tired to go through the source code of |
Thank your for your fast reply! So here are my example sample_data, taxa_table and otu_table. inf_test.csv I have created the phyloseq object and the taxonomy representation as follows: phy.info <- sample_data(inf) comp_barplot(phy, tax_level = "Phylum", n_taxa = 11, label = "inf.sample_short", sample_order = sample_names(phy)) + |
Sorry for bothering with this again, but can this problem be shown with just base R + ggplot2 + ggh4x? |
Hello @teunbrand, |
Hey @teunbrand,
thank you for your great package!
I was wondering if there is an option to use the remove_labels="x" option together with independent="x" from facet_grid2, if the labels are identical.
I will describe my issue from the very beginning:
I'm working with comp_barplot from the microVIZ package (https://github.com/david-barnett/microViz) and I encountered a problem when using facet_grid from ggplot2. Each x-axis label was repreated four times, but three times without the corresponding data plotted.
comp_barplot(phy.merged.rep, tax_level = "Phylum", n_taxa = 11, label = "sample_short", sample_order = sample_names(phy.merged.rep)) +
facet_grid(id ~ racon, scales = "free") +
theme_bw() +
theme(panel.grid.major = element_blank(),
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1),
axis.title.y = element_text(size = 10, vjust = 3, face = "plain")) +
guides(col = FALSE, shape = guide_legend(override.aes = list(size = 2.5)))
Then I found your package and was able to only plot the data on the x-axis were data points are actually available with the independent="x" option.
comp_barplot(phy.merged.rep, tax_level = "Phylum", n_taxa = 11, label = "sample_short", sample_order = sample_names(phy.merged.rep)) +
facet_grid2(id ~ racon, scales = "free", independent="x") +
theme_bw() +
theme(panel.grid.major = element_blank(),
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1),
axis.title.y = element_text(size = 10, vjust = 3, face = "plain")) +
guides(col = FALSE, shape = guide_legend(override.aes = list(size = 2.5)))
Now I would like to get rid of the x-axis labels and only display them at the outer margins (remove_labels="x"), as the labels are identical anyways. However, I learned that remove_labels cannot be used together with independent.
Is there any solution for me to get rid of the identical x-axis labels?
Best,
Dana
The text was updated successfully, but these errors were encountered: