Questions tagged [cowplot]

The cowplot package is a simple add-on to ggplot2. It is meant to provide a theme for ggplot2 that is especially useful for formatting plots for publication in academic journals, and it also provides tools to neatly arrange multiple plots of different types, while minimizing the amount of required fiddling with sizes of axis labels, plot backgrounds, etc.

Cowplot

The cowplot package is a simple add-on to ggplot2. It is meant to provide a theme for ggplot2 that is especially useful for formatting plots for publication in academic journals, and it also provides tools to neatly arrange multiple plots of different types. while minimizing the amount of required fiddling with sizes of axis labels, plot backgrounds, etc.

Official CRAN Documentation

https://cran.r-project.org/web/packages/cowplot/index.html

CRAN Resources

284 questions
2
votes
1 answer

In a grid of ggplot patchwork/cowplot/etc., how to align *only the outer boundaries* of the plots?

I have several plots with lengthy legends: (example plot using iris, NOT my actual plot) library(tidyverse) library(patchwork) theme_template <- theme_classic() + theme( # add border all around plot panel.border = element_rect(colour =…
ErwinTATP
  • 162
  • 6
2
votes
1 answer

Adding a master x-axis title to a multipanel grid of plots using ggdraw(), plot_grid() and ggsave() works in pdf but not jpg

I am creating a large 2 x 4 multi-graph panel using the packages described in the title. I have created a separate object as a master x-axis title spanning the graphs using ggdraw() and draw_label() from the cowplot package, which I have placed…
llewmills
  • 2,959
  • 3
  • 31
  • 58
2
votes
2 answers

R: cowplot plot_grid centering single figure on one row

With three individual plots plot1, plot2 and plot3, the command plot_grid(plot1, plot2, plot3, ncol = 2) creates a 2 x 2 plot area, in which the top row consists of two plots and the bottom row of a single plot aligned to the left. Hence, the bottom…
Maarölli
  • 375
  • 1
  • 3
  • 13
2
votes
1 answer

Cowplot plot_grid remove space from ggplot facet strips

I am assembling two ggplot objects with plot_grid, each of which uses the same facets, to give an effect of a grid of plots but with different x-axes. I only need the facet text to be on the first ggplot object, however, plot_grid seems to preserve…
brendaisy
  • 71
  • 5
2
votes
1 answer

Combine multiple patchworks

I would like to combine multiple plots created by patchwork in another patchwork, i.e. nested patchwork plots. Dummy plots # packages require(ggplot2) require(patchwork) # plots gg_hist = ggplot(iris) + geom_histogram(aes(x = Sepal.Length), color…
andschar
  • 3,504
  • 2
  • 27
  • 35
2
votes
1 answer

How to increase the resolution of ggplots in Rmarkdown html files

I am trying to knit an Rmarkdown document which contains a rather large ggplot, that I have created using cowplot This is how one might create such a plot: library(DOSE) library(cowplot) library(enrichplot) data(geneList) de <-…
nhaus
  • 786
  • 3
  • 13
2
votes
1 answer

multiple different sized plots in same window in R?

Similar questions have been asked many times, for example here and here. However, all of the other answers I have seen so far don't really solve my problem. I am trying to plot multiple different sized plots in the same window. I am working with…
Electrino
  • 2,636
  • 3
  • 18
  • 40
2
votes
1 answer

How to guarantee exactly equal size of faceted plots across different plots?

I'm doing something like the following. I tend to use cowplot for saving images of ggplot-generated plots but non-cowplot solutions are also fine. The first plot produces three facets (and one empty space) in a 2x2 arrangement, the second produces 6…
Ben S.
  • 3,415
  • 7
  • 22
  • 43
2
votes
1 answer

Combine correlation plot with coefficient table (ggplot2 -> ggstatsplot)

What are your preferred techniques for combining a table with a plot in one image using R? I remember using tableGrob() and either patchwork or cowplot months ago but cannot remember the details. This example uses the ggstatsplot package. I would…
Rick Pack
  • 1,044
  • 10
  • 20
2
votes
1 answer

combine and align ggplot, including one square with control of their height

I'm trying to vertically align several ggplots, including one that must be square (using coord_fixed or any other means). I also want to be able to control the relative heights of the different plots. The desired plot look would like this, the…
Benoit
  • 21
  • 1
2
votes
2 answers

ggplot: Add annotations using separate data above faceted chart

I'm trying to add set of markers with text above the top of a faceted chart to indicate certain points of interest in the value of x. Its important that they appear in the right position left to right (as per the main scale), including when the…
Chris
  • 1,449
  • 1
  • 18
  • 39
2
votes
2 answers

How do I align a histogram and boxplot so that they share x-axis?

Data wages # A tibble: 1,472 x 3 wage educ exper 1 7.78 1 23 2 4.82 1 15 3 10.6 1 31 4 7.04 1 32 5 7.89 1 9 6 8.20 1 15 7 8.21 1 26 8 10.4 1 23 9…
umair durrani
  • 5,597
  • 8
  • 45
  • 85
2
votes
1 answer

Aligning a violin plot with a forest plot

The violin plot (b) doesn't seem to align well with the forest plot (a). While the 5th column seems to align well, all other columns do not. I've tried the plot_grid, ggarange, grid_draw functions and they don't seem to fix the alignment. My…
Gerard Yu
  • 31
  • 2
2
votes
1 answer

How to use superscripts in cowplot multipanel plot labels

How can I use cowplot to add labels to plots in multiplot panels, where the labels have superscripts? I can use superscripts on the axis titles with substitute, bquote or expression, like this: library(ggplot2) library(cowplot) p1 <- ggplot(mtcars,…
Ben
  • 41,615
  • 18
  • 132
  • 227
2
votes
2 answers

How to force multiple r plots to have the same length of x-ticks?

Several packages in R are able to arrange mulitple plots into a grid, such as gridExtra and cowplot. The plots in the same row/column is by default aligned on their boundary. The following is an example. Three histograms are vertically arranged on…