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
27
votes
2 answers

Joining a dendrogram and a heatmap

I have a heatmap (gene expression from a set of samples): set.seed(10) mat <- matrix(rnorm(24*10,mean=1,sd=2),nrow=24,ncol=10,dimnames=list(paste("g",1:24,sep=""),paste("sample",1:10,sep=""))) dend <- as.dendrogram(hclust(dist(mat))) row.ord <-…
dan
  • 6,048
  • 10
  • 57
  • 125
25
votes
1 answer

ggplot - Multiple legends arrangement

I want to arrange mutiple legend in ggplot with multiple rows and columns. However currently, from the documentation I can only decide there direction or manipulate rows/columns within 1 legend. Am I overlook something? Thanks for any reference…
Sinh Nguyen
  • 4,277
  • 3
  • 18
  • 26
21
votes
5 answers

How to align an ordinary ggplot with a faceted one in cowplot?

I'm trying to arrange plots for publication with the use of cowplot package. I just want the panels to be equally sized and labelled. Reproducible example library(ggplot2) library(cowplot) gg1 <- ggplot(mtcars)+ …
ikashnitsky
  • 2,941
  • 1
  • 25
  • 43
19
votes
2 answers

One shared legend for a cowplot grid in R

I just built a grid with package cowplot (to label the plots from A-D). The plots are made with package ggplot2: pfour<-ggplot(four, aes(x=Concentration, y=Percentage, fill=Phenotype)) + geom_bar(stat='identity',color='black') + …
Kai Mayer
  • 197
  • 1
  • 1
  • 7
16
votes
1 answer

Cowplot made ggplot2 theme disappear / How to see current ggplot2 theme, and restore the default?

I recently installed the cowplot package. However, after doing this I noticed that my ggplots are missing their background and grid lines of theme_grey()! The code to create each of the above plots is: result_df %>% ggplot(aes_string(x = 'p', y…
Alex
  • 15,186
  • 15
  • 73
  • 127
14
votes
2 answers

Decrease margins between plots when using cowplot

I would like to combine some graphs together using cowplot. But I cannot change the margin sizes. I want to use only one y-axes, but than the margin is still quite large, which I want to decrease. I have used the plot.margin code from ggplot,…
Marinka
  • 1,189
  • 2
  • 11
  • 24
12
votes
2 answers

Disable cowplot default for ggplots

The ggplot2 add-on package, cowplot, has a nice function for plotting multiple plots called plot_grid(). Here's plot_grid() in action: library(ggplot2); library(cowplot) plot_a <- ggplot(mtcars, aes(mpg, wt)) + geom_point() plot_b <- ggplot(mtcars,…
luciano
  • 13,158
  • 36
  • 90
  • 130
12
votes
2 answers

Centered X-axis label for muliplot using cowplot package

I have a multiplot figure consisting of 4 plots in a 2x2 configuration. I arranged the plots using the "cowplot" package and the plot_grid function using the code below plot_grid(p1, p2, p3, p4, align='vh', vjust=1, scale = 1) where p1-p4 are my 4…
Jason
  • 892
  • 1
  • 8
  • 19
10
votes
2 answers

Using cowplot in R to make a ggplot chart occupy two consecutive rows

This is my code: library(ggplot2) library(cowplot) df <- data.frame( x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3, y4 = (1:10)^4 ) p1 <- ggplot(df, aes(x, y1)) + geom_point() p2 <- ggplot(df, aes(x, y2)) + geom_point() p3 <- ggplot(df,…
Laura
  • 675
  • 10
  • 32
10
votes
2 answers

ggplot2: Creating themed title, subtitle with cowplot

I have a list of data frames that I use to make a list of ggplots, and then assemble into a grid of plots with cowplot. I need to then attach a shared title, subtitle, and caption. I want to do this in a way that these labels will have the same…
camille
  • 16,432
  • 18
  • 38
  • 60
10
votes
1 answer

Merge and Perfectly Align Histogram and Boxplot using ggplot2

since yesterday I am reading answers and websites in order to combine and align in one plot an histogram and a boxplot generated using ggplot2 package. This question differs from others because the boxplot chart needs to be reduced in height and…
Seymour
  • 3,104
  • 2
  • 22
  • 46
8
votes
1 answer

Draw border around certain rows using cowplot and ggplot2

I want to somehow indicate that certain rows in a multipanel figure should be compared together. For example, I want to make this plot: Look like this plot (with boxes around panels made with PowerPoint): Here's the code I made to use the first…
user2917781
  • 273
  • 2
  • 10
8
votes
2 answers

How to put plots without any space using plot_grid?

I'm doing an arrangement of 2x2 plots. The plots share the same axis, so I want to put them together, e.g. This code: library(ggplot2) library(cowplot) Value <- seq(0,1000, by = 1000/10) Index <- 0:10 DF <- data.frame(Index, Value) plot <-…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
8
votes
1 answer

Using Cowplot for a list of plots using paste0

I have a list of ggplots from 1:10 called plot_1,plot_2....plot_10. I wanted to use cowplot to display all plots together. How can I use plot.grid() to call all plots? i.e I want to write something like plot.grid(paste0("plot",1:10)) but this…
Birdonawire
  • 199
  • 3
  • 10
7
votes
3 answers

How to align and avoid overlapping of multiple legends that are created separately and then added to the plots?

I am trying to create a plot that combines 2 separate legends and a grid of multiple plots. The issue I'm having is I'm finding it difficult to align the legends so they are visible and not overlapping. hopefully the example below will explain what…
Electrino
  • 2,636
  • 3
  • 18
  • 40
1
2 3
18 19