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
3 answers

How to add labels to multiple ggplot graphs (A, B, C)

I am trying to add the labels A, B, and C to the top left hand corner of each of these graphs. I have tried cowplot::draw_plot_label(), but nothing seems to work. Can anyone help? These A, B and C labels are not the main title of each plot. #…
2
votes
1 answer

Right align horizontal y axis titles for multiple plots using R ggplot2

I'm having trouble right aligning horizontal y axis titles for multiple plots in R ggplot2. I have a main plot which is a dendrogram with leaf labels created using the ggdendro package, and I have multiple color bars below the main plot with titles…
Ben Ernest
  • 445
  • 3
  • 14
2
votes
2 answers

Adjust spacing between subplots of panel figure (ggplot) in case of different axis.title/text properties

I would like to adjust the spacing between plots that are aligned in a panel using the cowplot package when some plots contain axis titles/labels, and others don't. Example Let's create three…
user213544
  • 2,046
  • 3
  • 22
  • 52
2
votes
2 answers

How to align legends included in the plots of the last column of an arrange of plots using `plot_grid` from `cowplot` package?

I have arranged 16 plots (4x4) using plot_grid from cowplot package. I would like to align last column of my arrange to get all the legends to be symmetrical vertically. I have read this but I don't get what I want. I don't know why it doesn't…
Dekike
  • 1,264
  • 6
  • 17
2
votes
2 answers

Align plots of different widths on x-axis scale values

How to align two plots with different widths so that: their x-axes are in sync the top row also contains a common legend I basically want each x-axis-interval to correspond to the same amount of centimeters on the two plots. I have tried…
Rasmus Larsen
  • 5,721
  • 8
  • 47
  • 79
2
votes
1 answer

Placement of legend using plot_grid of cowplot

I am trying to place the legend below a plot_grid but it just appears to the right of them. I thought the position was governed by the theme(legend.position = 'bottom') in the get_legend(...) statement. What am I doing wrong? Example code to…
Stefan Hansen
  • 499
  • 1
  • 3
  • 16
2
votes
2 answers

How to align bar plots vertically to get same width for each bar with different numbers of x

I'm using cowplot package to create a plot grid. My problem comes when I want to plot vertically two plots with different widths. Here is an example: library(dplyr) library(ggplot2) library(cowplot) plot1 = iris %>% ggplot(aes(x = Species, y =…
Archymedes
  • 431
  • 4
  • 15
2
votes
0 answers

Aligning origin and X-axis using Cowplot or ggpubs in R

I'm trying to arrange 2 plots that will utilise a common x-axis, the first plot represents market demand for a product, the second represents products available and how they compare to competitors. The aim is to represent the two plots on a single…
2
votes
0 answers

cowplot, shared legend, spacing goes wrong when output to png

I have a problem with combining ggplots using cowplot and ggpubr which is driving me crazy. The problem is with the legend. When it's displayed with its original graph on its own, the spacing between the elements of the legend (guide title, key,…
mpgrayer
  • 33
  • 4
2
votes
2 answers

Difficulty in arranging plots

I have total 7 plots. Six of them are line charts which are to be aligned and arranged one below each other such that there is no space between them - to make one composite plot. Here is the data and ggplot2 code and I am using the same line chart…
Kou
  • 57
  • 1
  • 7
2
votes
2 answers

Setting width and height of a single panel in multi-panel plot in cowplot::plot_grid

I am making a multi-panel plot using ggplot2 and cowplot packages, but I need to change the height of a single plot. It is easiest shown with an example library(ggplot2) library(cowplot) p1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour =…
llewmills
  • 2,959
  • 3
  • 31
  • 58
2
votes
2 answers

How to remove awkward vertical gap between the two legends I created for Cowplot in R?

I tried to create two separate legends because I wanted to group my legends differently. However, there is this awkward gap between both legends; I want to close the awkward vertical gap between the two legends (as pictured). How can I go about…
catlovingtaco
  • 123
  • 10
2
votes
0 answers

Customize legend labels for continuous variables cut into several categories in ggplot2

I am drawing a choropleth map for US counties. I randomly created a variable dumb that is uniformly distributed between 1 and 100 and cut it into 6 categories, which is stored as dumb_quantiles. I then mapped dumb_quantiles categories to counties of…
Patrick
  • 1,057
  • 9
  • 23
2
votes
1 answer

How align plots by 0 on Y axis with plot grid?

I have 3 plots with different scales, and I want align them by 0. I tried playing with align in plot_grid, but without results. Dataframes for the three different plots: 1 higherperiod=structure(list(phen = c("GS0", "GS1", "GS2", "GS3", "H", "GS0",…
Antonio Manco
  • 217
  • 2
  • 14
2
votes
1 answer

ggplot2 in combination with rworldmap

I make the following rworldplot: library(rworldmap) #> Loading required package: sp #> ### Welcome to rworldmap ### #> For a short introduction type : vignette('rworldmap') library(RColorBrewer) test.data <- data.frame( country =…
CodeNoob
  • 1,988
  • 1
  • 11
  • 33