Reputation: 1151
I am trying to combine 2 ggplots and 1 upset plot in R. However upset plot is giving me a problem: when I try to combine the B and C graghs overlap with upset_plot. Is there a way to transform it in grob without this problems?
# Plot
upset_plot <- upset(fromExpression(input),
#nintersects = 40,
nsets = 6,
order.by = "freq",
decreasing = T,
mb.ratio = c(0.6, 0.4),
number.angles = 0,
text.scale = 0.8,
point.size = 2.0,
line.size = 0.8,
sets.bar.color = "#56B4E9",
set_size.show = FALSE
)
upset_grob <- grid.grabExpr({print(upset_plot)}, wrap.grobs=TRUE)
# Check if the plot has been captured properly
if (!is.null(upset_grob)) {
print("Plot captured successfully!")
} else {
print("Plot capture failed!")
}
# To view the plot:
grid.draw(upset_grob)
# Combine the plots with patchwork, making the third row taller
combined_plot <- (A / upset_grob / (B + C)) # Make the third row taller
# Draw the combined plot
print(combined_plot)
Upvotes: 0
Views: 17