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

Setting width in gtable object collapses plot; this used to work but it doesn't anymore.

The following code used to work but doesn't anymore. Does anybody have an idea what's going on? It must be some change in the underlying gtable code. require(cowplot) # for plot_grid() require(grid) # for unit_max() # make two plots plot.iris <-…
Claus Wilke
  • 16,992
  • 7
  • 53
  • 104
3
votes
1 answer

can not left align with cowplot package

In the current plot, p2 is now centered. I want p2 to be aligned with p1 on the left. I tried some of the parameters in plot_grid, but the image didn't change at…
zhiwei li
  • 1,635
  • 8
  • 26
3
votes
0 answers

ggplot: fonts not found and strange spacing (maybe related to macOS)

I am struggling to apply fonts in ggplot on macOS and need some help. Hopefully this will help others too as I've searched a lot and tried all sorts to no avail. Fonts that appear to be there are not recognised and then strange spacing happens…
Chris
  • 1,449
  • 1
  • 18
  • 39
3
votes
1 answer

Fixed width of legend box using ggplot, gtable and cowplot

I would like to make a plot with R that looks like the sample made with Mac's Numbers. I'm struggling with the space between the plot and the legend box. This is a sample of what I would like to achieve: With the help of some users (see end of post…
thuettel
  • 165
  • 1
  • 11
3
votes
1 answer

Combine tmap and ggplot

I am trying to combine test1, a map made with tmap, with test2, a plot made with ggplot2, using cowplot::plot_grid. library(ggplot2) library(tmap) library(cowplot) library(ggplotify) test2 <-ggplot(iris, aes(Sepal.Length, Sepal.Width, color =…
Jana
  • 33
  • 4
3
votes
0 answers

Include multiple figures with knitr::include_graphics() in a single chunk an each figure with its own label (A, B, C, ...)

I would like to include several jpg/png figures side by side and each labeled by a letter (A, B, C, ...) in a Rmarkdown report compiled to both PDF and HTML. Including the figures side by side is easy with knitr::include_graphics() and setting…
mavericks
  • 1,005
  • 17
  • 42
3
votes
1 answer

Left-aligning ggplot when saved while using a fixed aspect ratio

I'm building a custom ggplot theme to standardize the look & feel of graphs I produce. The goal is more complex than this minimal example, so I'm looking for a general solution. I have a few key goals: I want all graphs to export at the same size…
Michael Toth
  • 75
  • 10
3
votes
2 answers

Align plot with different axes vertically using Cowplot

I am trying to align three plots (with different scales on the y-axis) on the left y-axis. In other words, I would like the red axis to be aligned: However, the y-axis of the first plot does not align with the y-axis of the bottom left plot.…
user213544
  • 2,046
  • 3
  • 22
  • 52
3
votes
2 answers

is there gridExtra/cowplot type package in Python to use with Plotnine to align subplots (i.e. marginal distributions)

This is related to the following posts on aligning subplots in ggplot2 in R: Scatterplot with marginal histograms in ggplot2 How to plot Scatters with marginal density plots use Python? Perfectly align several plots There are many more links on…
codingknob
  • 11,108
  • 25
  • 89
  • 126
3
votes
1 answer

extracting individual plot details from combined plot in `cowplot` for unit tests

I am trying to write unit tests for functions where I use cowplot::plot_grid() to combine ggplot2 plots. For example, # setup set.seed(123) library(ggplot2) # creating basic plots p1 <- ggplot(aes(x = as.factor(am), y = wt), data = mtcars) + …
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
3
votes
2 answers

Return graph from function without plotting it

I want to write function which returns a graph but it should not plot the graph. It should only plot the graph when I ask it to. Here is a MWE. graph_functions <- function(x) { plot(1:length(x), x) points(1:length(x), x^2) t <- recordPlot() …
user2338823
  • 501
  • 1
  • 3
  • 16
3
votes
3 answers

Change background color with plot_grid

how can I change the background color, when using plot_grid? I have the following graphic, but I want everything in the background to be grey and not have the difference in heights. How can I change this? Here is my code for the graphics and the…
Mucteam
  • 345
  • 3
  • 12
3
votes
0 answers

Error in cowplot::plot_grid: unused arguments (plot.c, plot.def, labels = "AUTO") and Error in arrangeGrob(...) : nrow * ncol >= n is not TRUE

When I run the code below from here I get the error: Error in plot_grid(plot.a, plot.b, plot.c, plot.def, labels = "AUTO") : unused arguments (plot.c, plot.def, labels = "AUTO") When I remove the unused arguments from the plot_grid the error…
Krantz
  • 1,424
  • 1
  • 12
  • 31
3
votes
2 answers

Use cowplot in R to align image() plots

I would like to align two plots in R, generated with the image() function. Sample code: # Load package library(cowplot) # Plot sample image image <- image(matrix(rnorm(1000), 100,100)) # Align plots plot_grid(image, image) However, when I do it…
user213544
  • 2,046
  • 3
  • 22
  • 52
3
votes
1 answer

R graphics: How to make objects from VennDiagram compatible with cowplot plot_grid?

I am making Venn diagrams with the VennDiagram package. They are coming out OK: library(VennDiagram) library(cowplot) png("p.png") p = draw.pairwise.venn(30,20,11, category = c("Dogs", "Cats"), lty = rep("blank", 2), fill = c("light blue",…
phlatphish
  • 95
  • 5