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
3
votes
1 answer

plot multiple plots with legends from other plots beside

I have three plots p1, p2 and p3. I would like to combine p2 and p3 and add the legends of p2 and p1 on the right side above each other. In the following example the legends are identical. In the real data they are differend. I use ggplot2 and…
captcoma
  • 1,768
  • 13
  • 29
3
votes
2 answers

Adding x and y laxis label to ggplot-grid build with cowplot

I produced a grid with cowplot: library(ggplot2) library(cowplot) ggg1 <- ggplot(mtcars, aes(mpg,vs)) + geom_point() + theme(axis.title.x=element_blank(), axis.title.y=element_blank()) ggg2 <- ggplot(mtcars, aes(mpg,vs)) + geom_point() + …
Make42
  • 12,236
  • 24
  • 79
  • 155
3
votes
1 answer

Add empty plots to facet, and combine with another facet

Using this SO solution I created a facet with two "empty" plots, with the aim of combining with another group of facet_wrap plots, as shown below. The purpose is to have two y-axis labels for different unit measurements. How can I make the grid…
Anonymous coward
  • 2,061
  • 1
  • 16
  • 29
3
votes
2 answers

Vertically align of plots of different heights using cowplot::plot_grid() when using coord_equal()

I am trying to combine two ggplot objects using cowplot::plot_grid() and vertically align them. This is normally quite simple using align = "v". dat1 <- data.frame(x = rep(1:10, 2), y = 1:20) dat2 <- data.frame(x = 1:10, y = 1:10) plot1 <-…
Kevin
  • 491
  • 3
  • 10
3
votes
3 answers

How can I scale nested plot_grid to the same size?

I have 7 plots and I organize them in 2 columns, one with 3 plots and other one with 4 plots. I used plot_grid from cowplot for that. The result is almost perfect, however, the column with 3 plots has bigger plots. How can I scale this column to get…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
3
votes
2 answers

cowplot: How to customize the gaps between main panel & marginal plots by modifying axis limits?

This is a followup question on one of the solutions provided by @ClausWilke (see post) to insert gap between main panel & marginal plots. How does one decide the (scale_x_continuous) limits? Also, what’ll happen if we used “NA” as the upper…
Vikrant
  • 125
  • 8
3
votes
1 answer

Marginal plots using axis_canvas in cowplot: How to insert gap between main panel and marginal plots

The following came up in a comment to this post: When making marginal plots with the axis_canvas() function in cowplot, how can we create a gap between the main plot and the marginal plot? Example code: require(cowplot) pmain <- ggplot(data = mpg,…
Claus Wilke
  • 16,992
  • 7
  • 53
  • 104
3
votes
1 answer

Arrange 8 plots and a legend in a grid

I have 8 plots and one legend that I would like to arrange in a 3x3 grid, so that the axes all align. It works perfectly fine when I am not including the legend to my grid, but as soon as I have added the legend, my plots get shifted and are no…
Servus
  • 373
  • 3
  • 14
3
votes
1 answer

Multiple pages, with several ggplot2 graphs and tables per page, coming from several data frames, each page being the level of a common factor

I have different data frames providing information on the same levels of the same factor. Eventually I'd like to have a pdf containing, for each page, ggplot2 graphs, a gridExtra tableGrob and text as title, coming from the different data frames.…
A. Boul.
  • 33
  • 6
3
votes
1 answer

rel_heights in plot_grid not responding

I have two ggplots I'm trying to put together using cowplot's plot_grid: First data.frame and ggplot: require(ggplot2) main.df <-…
user1701545
  • 5,706
  • 14
  • 49
  • 80
3
votes
4 answers

R assigning ggplot objects to list in loop

I'm using a for loop to assign ggplots to a list, which is then passed to plot_grid() (package cowplot). plot_grid places multiple ggplots side by side in a single figure. This works fine manually, but when I use a for loop, the last plot generated…
3
votes
1 answer

Arrange multiple ggplots, but avoid squishing due to axis label

I've been using cowplot::plot_grid to arrange multiple ggplot figures, which has been working great in general. However, I've now run into a problem where I want to include the x axis labels on just the bottom plot, but it ends up squishing all the…
3
votes
2 answers

Two ggplots in one figure, plotted close together

I'm looking to plot a filled contour with geom_tile and the corresponding raw trace directly below it with no space between the two. When using gridExtra or cowplot, I can get them close but not to where the top of raw trace is on the x axis of the…
Ted Mosby
  • 1,426
  • 1
  • 16
  • 41
2
votes
2 answers

Problem with cowplot in R: when paneling grobs and exporting as pdf, bullets turn into ellipses

I have a rather peculiar problem in paneling with cowplot and exporting the result as a PDF file. Consider the following MWE: # Load libraries library(consort) library(cowplot) library(ggplotify) # Create data for flowchart A participant_id <-…
jaggedjava
  • 440
  • 6
  • 14
2
votes
0 answers

Using long legend name in scale_fill_gradientn cause legend box to be off-centered, and more when use with cowplot functions ggdraw and draw_plot

I wonder how could I fix the position of my legend box in the bottom-middle of my map, specifically when I using inset plot with cowplot functions. I tried various ways but it didn’t work. Would appreciate any help on this. Here is a reproducible…
rez
  • 290
  • 2
  • 12