I am trying to move the y axis title towards the ticks. However, I'm having trouble doing this without cutting off the combmatrix labels. I've tried both with ggupset
and ggplot
functions. See reprex below.
Thank you for your help!
library(dplyr)
library(ggupset)
library(ggplot2)
tidy_pathway_member <-
gene_pathway_membership %>%
as_tibble(rownames = "Pathway") %>%
tidyr::gather(Gene, Member, -Pathway) %>%
filter(Member) %>%
select(- Member)
g <-
tidy_pathway_member %>%
group_by(Gene) %>%
summarize(Pathways = list(Pathway)) %>%
ggplot(aes(x = Pathways)) +
geom_bar() +
scale_x_upset()
g
g +
# Moves axis title towards ticks...but cuts off labels
theme_combmatrix(combmatrix.label.make_space = FALSE)
g +
# Also, moves axis title towards ticks...but cuts off labels
theme(axis.title.y = element_text(margin = margin(r = -100)))
Created on 2021-07-30 by the reprex package (v2.0.0)
Like this?
library(dplyr)
library(ggupset)
library(ggplot2)
tidy_pathway_member <-
gene_pathway_membership %>%
as_tibble(rownames = "Pathway") %>%
tidyr::gather(Gene, Member, -Pathway) %>%
filter(Member) %>%
select(- Member)
g <-
tidy_pathway_member %>%
group_by(Gene) %>%
summarize(Pathways = list(Pathway)) %>%
ggplot(aes(x = Pathways)) +
geom_bar() +
scale_x_upset() +
# the exact vjust number needed may vary depending on the plotting area size
theme(axis.title.y = element_text(vjust=-30))
g
BTW the same solution should work for ComplexUpset in principle.