cowplot
Merge and Perfectly Align Histogram and Boxplot using ggplot2
You can use either egg, cowplot or patchwork packages to combine those two plots. See also this answer for more complex examples. library(dplyr) library(ggplot2) plt1 <- my_df %>% select(value) %>% ggplot(aes(x=””, y = value)) + geom_boxplot(fill = “lightblue”, color = “black”) + coord_flip() + theme_classic() + xlab(“”) + theme(axis.text.y=element_blank(), axis.ticks.y=element_blank()) plt2 <- my_df %>% select(id, … Read more
Multiple plots in for loop ignoring par
Here is one way to do it with cowplot::plot_grid. The plot_duo function uses tidyeval approach in ggplot2 v3.0.0 # install.packages(“ggplot2”, dependencies = TRUE) library(rlang) library(dplyr) library(ggplot2) library(cowplot) plot_duo <- function(df, plot_var_x, plot_var_y) { if (is.character(plot_var_x)) { print(‘character column names supplied, use ensym()’) plot_var_x <- ensym(plot_var_x) } else { print(‘bare column names supplied, use enquo()’) plot_var_x … Read more