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
1
vote
2 answers

Displaying saved ggplots in a grid when saved in a matrix in r

I have created plots using a loop and saved them in a matrix (see my earlier question). I now want to arrange the plots in a grid using plot_grid or similar. Is there a simple way to call the matrix of saved plots? I want the resulting grid of…
Esme_
  • 1,360
  • 3
  • 18
  • 30
1
vote
1 answer

is there a way to adjust theme of a cowplot object?

Can I change the theme of a combined plot? Example: library(ggplot2) library(cowplot) p1 = ggplot(diamonds, aes(x = price)) + geom_histogram(bins = 30) p2 = ggplot(diamonds, aes(x = table)) + geom_histogram(bins = 30) p =…
invictus
  • 1,821
  • 3
  • 25
  • 30
1
vote
0 answers

Size of figures in knitr with patchwork or cowplot

I have a large number of figures which I would like to present in a single column in a document created with knitr. The number of figures can vary, so I created a function to combine all figures using patchwork::wrap_plots (cowplot::plot_grid is an…
simoncolumbus
  • 526
  • 1
  • 8
  • 23
1
vote
0 answers

Finding ggsave and save_plot do not seem to work with the ggdraw+draw_grob from the cowplot package?

I cannot seem to save a plot when using ggdraw() + draw_grob(). Saving just 'plot1' alone works fine but once I start using ggdraw it no longer works with either ggsave() or save_plot(), it produces an error noting an invalid canvas value. Example…
andrew
  • 11
  • 2
1
vote
2 answers

Horizontally align bars and facets

I have this two data.frames df1 <- data.frame(unit = factor(1:20, levels = 20:1), value = sample(1:10, 20, replace = T)) df2 <- data.frame(unit = factor(as.vector(sapply(1:20, FUN = function(x) rep(x, 10))). …
CptNemo
  • 6,455
  • 16
  • 58
  • 107
1
vote
1 answer

Put many heatmap images in one single slide

I have 3 heatmap plots generated using CRAN package heatmap. I want to put these three images in one slide then I used the following command cowplot::plot_grid(mfs, mfs_ma, mfs_fe,ncol= 3, labels=LETTERS[1:3]) but it return me Warning messages: In…
adR
  • 305
  • 4
  • 14
1
vote
1 answer

How to deminish margins between legends in cowplot

Arranging multiple legends is a common issue when preparing plots in R. The theme() function in ggplot2 package allows to arrange multiple legends in either horizontal or vertical direction. However, in some cases, some legends are long, and others…
Yiwei Zhu
  • 25
  • 3
1
vote
0 answers

cowplot::axis_canvas lines do not match with the plot when scale_y_continuous with expand argument

I would like to annotate the plot using cowplot package, but when plot uses scale_y_continuous with expand argument, same values on plot and axis_canvas are not aligned. When I remove the expand argument, then everything is nicely aligned. I need…
1
vote
0 answers

Click location from multiple aligned plots in Shiny

I'm trying to combine two plots in Shiny using cowplot/plot_grid, and I'd like to be able to get the x coordinate for clicks. When I have a single plot, not using plot_grid, I get an x value in the scale of the x axis. When I have two plots,…
A. Braver
  • 35
  • 4
1
vote
0 answers

saving multiple plots with overall legend in a list to plot over multiple pages using marrangeGrob cowplot

I'm trying to save plots with one overall legend per page over multiple pages in a pdf using cowplot and marrangeGrob but I'm struggling to save the final step to a pdf. I can save plots on one page following this question.…
user63230
  • 4,095
  • 21
  • 43
1
vote
1 answer

How to reduce plot margins of one column of plots of an arrange of plots using `plot_grid` in R?

I need to make an arrange of plots in which each row of plots shares a common legend. All plots share the same units for y and x-axis. Below I show how my arrange of plots looks like: I extract the common legend for each row as a plot and then I…
Dekike
  • 1,264
  • 6
  • 17
1
vote
0 answers

How to add variables into graph margins using R?

I'd like to add variable information (for instance "Case" from the data) in the margin (horitzontal or vertical) that changes with each year - preferably more than one variable actually - similar concept to what ggMarginal would produce but the…
arks
  • 55
  • 8
1
vote
1 answer

Adjust margins of grob object in r

I made a grob object using the cowplot package. I'm adding grid.lines() and grid.text() objects to finished grob but as it comes out of cowplot it fills the whole page. How can I adjust the margins of the grob object to add some white space around…
CCurtis
  • 1,770
  • 3
  • 15
  • 25
1
vote
1 answer

"Labelling" the tick marks in ggplot2?

I wanted to make a plot to help people understand the different pieces of a plot in ggplot2. I am still mid-draft, but I am currently struggling on labeling the axis.ticks because they are off the plot. Intuitively I thought I could do this with…
John-Henry
  • 1,556
  • 8
  • 20
1
vote
1 answer

how to fit multiple ggplot charts on a a4 pdf?

Consider this simple example library(dplyr) library(ggplot) library(patchwork) mytib <- tibble(group = as.factor(c(1,1,1,1,2,2,2,2,3,3,3,3)), y = c(1,2,3,42,50,400,3,3,2,3,3,4), x =…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235