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

How to create cowplot panel with side and top headings and a common legend?

I want to create a choropleth panel with side and top headings and a common legend. I am plotting a choropleth over the state of Texas for four different scenarios. I want to show it as a 2x2 panel. I am using the plot_grid method from the R cowplot…
Ramaraja
  • 2,526
  • 16
  • 21
0
votes
1 answer

R rbind and display multiple plot()

I am fitting several simple linear regression models data("mtcars") head(mtcars) mtcars_lm <- plyr::dlply(mtcars, "cyl", function(x) lm(mpg ~ hp + wt + cyl,…
bison2178
  • 747
  • 1
  • 8
  • 22
0
votes
0 answers

Place ggplot in a specific coordinate of a background image by using ggdraw and draw_plot (cowplot)

I have this ggplot figure by using the well-known database mtcars. ggmtcars <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(size=2, shape=23) + geom_hline(aes(yintercept = 0), color = "red", lty = 2) + geom_vline(aes(xintercept = 0), color =…
antecessor
  • 2,688
  • 6
  • 29
  • 61
0
votes
0 answers

Cowplot failed to align legends to the left side

I get two legends using the function get_legend() and align them vertically. By default, they are aligned to the center. I fail to align them to the left side using the align="v",axis="l"options in the function plot_grid() (fig. B). A reproducible…
Yiwei Zhu
  • 25
  • 3
0
votes
1 answer

ggplot: separate positions of colorbar and color legend

I am trying to create a ggplot scatter plot with continuous fill and discrete color. I would like to place the colorbar at the bottom and the color legend inside the panel (see image below). ggplot(mpg, aes(x = displ, y = cty, color = manufacturer,…
pavlopavlin
  • 120
  • 7
0
votes
1 answer

I have troubles with axis_canvas from cowplot package on R: "Error in zero_range(range) : x must be length 1 or 2"

I'm trying to add marginal boxplot next to a scatterplot that I've created with ggplot. To add the marginal boxplot I'm using the package cowplot (also because ggmarginal was always giving me boxplots of different width among them). Nevertheless it…
0
votes
1 answer

How to arrange multiple plots in using cowplot and ggplot

Edit: added image for reference https://prnt.sc/Lm5Kk9phys7i I have two plots that I am trying to combine into one image and then add additional texts. I am trying to: Add a blue background to the title bar Add a paragraph of text above each plot…
OTA
  • 269
  • 2
  • 17
0
votes
0 answers

cowplot::plot_grid() cuts off subplot edges if subplot much bigger than the other (happens at printing image into word file)

I have two tileplots: library(ggplot2) l1 <- 50 ncols <- 3 m1 <- matrix(rexp(l1*3, rate = .1), ncol = 1) %>% as.data.frame() %>% cbind(Comparison = rep(c("T1 vs C", "T2 vs C", "T3 vs C"), each = l1)) %>% cbind(ID =…
schd
  • 3
  • 1
0
votes
1 answer

plot_grid function removes axis breaks from ggbreak in plots

I'm struggling with a problem: I created two volcano plots in ggplot2, but due to the fact that I had one outlier point in both plot, I need to add y axis break for better visualization. The problem arises when I WANT TO plot both in the same page…
jonny jeep
  • 383
  • 3
  • 12
0
votes
0 answers

GGplot; two plots in the same graph with the same scale

I am calculating the number of mortalities over time (predicted and observed). I tried to visualise two fits with two different ggplots next to each other using the library(cowplot) package. The two ggplots are autoscaled by R on their own data but…
Fruuutz
  • 15
  • 3
0
votes
1 answer

Change the label position of each figure to the bottom with plot_grid

I would like to change the position of each label to the bottom and centered part of each figure, is it possible? 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 <-…
Velton Sousa
  • 345
  • 1
  • 9
0
votes
0 answers

R shared cowplot overlaps text with different font

I am working on a figure for a paper that uses calibri font with various font sizes (axis.text = 10, legend.text = 12, title = 14) that includes 2 ggplot plots and a shared legend on the bottom. I have found that if I define the font family, that…
Andrew
  • 105
  • 8
0
votes
1 answer

Having trouble aligning histogram and density plots in ggplot2 with cowplot

Only the stripped down density plot appears in the output: library(ggplot2) library(cowplot) raises <- attitude$raises df <- data.frame(raises) ph <- ggplot(df, aes(x = raises)) + geom_histogram(binwidth = 1, color = "black", fill = "light…
Alex M
  • 25
  • 4
0
votes
1 answer

ggarrange not showing axis labels

I have made 4 circular boxplots with ggplot2 and they look ok individually (although ideally, I would like the x-axis names further outside of the plot). But when I use ggarrange from the ggpubr package to make a multi-panel plot my axis names are…
ASHooper93
  • 27
  • 3
0
votes
0 answers

Sequential plot number in cowplot

I have created a list of plots called plot.list within a loop and called them with different names e.g. "tissue1_gene1_gene2", "tissue1_gene3_gene4",....,"tissue2_gene1_gene2, "tissue2_gene3_gene4",...., "tissue3_gene1_gene2",…
erikagucci
  • 21
  • 1