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

206 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
  • 4,868
  • 4
  • 35
  • 85
20
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,511
  • 20
  • 38
15
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
  • 3,191
  • 3
  • 14
  • 23
15
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
  • 13,293
  • 9
  • 60
  • 113
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
  • 11,848
  • 27
  • 77
  • 118
11
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
  • 117
  • 1
  • 1
  • 7
9
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
  • 2,413
  • 2
  • 13
  • 33
9
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
  • 734
  • 7
  • 15
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
  • 301
  • 1
  • 8
8
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
  • 949
  • 1
  • 10
  • 20
7
votes
1 answer

Is it possible to avoid axis label overlapping by ggrepel?

I am drawing heatmap with ggplot2. Several ticks on y axis need to be labeled. However,some of them are too close and overlap. I know ggrepel could separate text labels, but currently I have not worked out for my problem. My code is as following.…
PengY
  • 73
  • 4
7
votes
1 answer

Shared panel border with cowplot and plot_grid

I'm trying to draw a border around two plots that have been aligned with plot_grid from the cowplot package. Please see the following example (modified from the "Changing the axis positions" vignette): require(gtable) require(cowplot) # top plot p1…
tractorjack
  • 127
  • 8
6
votes
2 answers

ggplot: Boxplot by several categorical variables

I am trying to plot several boxplots in one chart using ggplot2. I have 1 continuous variable and several factors. I would like to have a single Y axis and each pair of boxplots to have their own x axis with their own factor levels. So far, I tried…
user2053921
  • 63
  • 1
  • 4
6
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
  • 13,812
  • 10
  • 29
  • 45
6
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.
  • 1,337
  • 2
  • 13
  • 28
1
2 3
13 14