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

custom labels beside a 1-column grid of plots, in R

Given a number (4) of ggplot objects of equal dimensions, when combining them into a figure as 1 column of plots, I would like custom text on left beside each plot. Combining the plots is easy with help of packages such as cowplot, ggarrange,…
0
votes
1 answer

How to create a faceting based on a column in second dataframe

I want to create a graph that looks like: Now I found the cowplot package which gave me a quite similar result. library(ggplot2) library(cowplot) library(data.table) library(ggridges) d = data.table(iris) a = ggplot(data = d, aes(x=Sepal.Length,…
Marco_CH
  • 3,243
  • 8
  • 25
0
votes
1 answer

Adaptively start a newline for ggplot text (title, subtitle, caption, etc.) using R

With code I plot a combined figure: library(ggplot2) library(tidyverse) library(patchwork) library(glue) library(cowplot) small <- mtcars %>% filter(carb %in% c(1, 2)) p1 <- qplot(mpg, wt, data = small, colour = cyl) p2 <- qplot(mpg, data =…
ah bon
  • 9,293
  • 12
  • 65
  • 148
0
votes
1 answer

In cowplot/add_sub, how to align the multiple text label?

In cowplot/add_sub, how do you align a multiple text label? Here is the code below. Thanks! library(ggplot2) library(cowplot) p1 <- ggplot(mtcars,aes(mpg,disp))+ geom_line(colour="blue")+ theme_half_open() p1_1 <- add_sub(p1,"this is an…
anderwyang
  • 1,801
  • 4
  • 18
0
votes
1 answer

How to use hjust to move the label on only one plot?

I am creating a multipanel graph using plot_grid of the relationship of discharge and surface area with species richness in Amazon Rivers. Here is my data: riverssub<-structure(list(richness = c(127L, 110L, 89L, 74L, 62L, 18L, 22L, 71L, 38L, 91L,…
0
votes
1 answer

R/graphics: Plotting to PNG in function

I want to use a function to have cowplot::plot_grid() write directly to a PNG. I can make it work from a script: g <- ggplot2::ggplot(datasets::iris, ggplot2::aes(x = Sepal.Length, y= Sepal.Width)) + ggplot2::geom_point() …
Timm S.
  • 5,135
  • 6
  • 24
  • 38
0
votes
2 answers

Save images in R

Does anyone use the function save_plot from the package cowplot to save the picture instead of ggsave. How we can set up the output? I did use the default setting and the output pic was set into…
Anh
  • 735
  • 2
  • 11
0
votes
1 answer

Change the ratio of image output

One guy just told me about using the function ggdraw to overlap two figure. When I saved the output using ggsave, the margin of both side (left, right) of my picture was shrank. I did use its arguments, but nothing happened. Does anyone know about…
Anh
  • 735
  • 2
  • 11
0
votes
1 answer

Creating space for text annotation to the right of a figure?

I am trying to annotate my ggplot figure with some text but I struggle to find an optimal solution. I want to create a margin to the right of the figure so that I can write Course A, Course B and Course C. Now I don't have enough space. I have tried…
Cmagelssen
  • 620
  • 5
  • 21
0
votes
1 answer

plot_grid - Labels unreadable,

I try to visualize non-normalized vs. normalized feature data in boxplots aligned next to each other with cowplot. Features are 57 variables numbered incremental plot_grid( sample_data1 %>% pivot_longer(-c(ID, outcome), names_to = "feature")…
Str1atum
  • 1
  • 2
0
votes
1 answer

Using bold font with GoogleFonts

I'm a bit lost at the moment: I have added a font to my R script via GoogleFonts and would now like to use the "bold" version. However, I can't find a way! I've already tried various things and it doesn't work - I'm expecting a simple solution, but…
LePyka
  • 181
  • 8
0
votes
1 answer

How to label lines obtained using split with ggrepel

I am trying to label 4 lines grouped by the value of variable cc. To label the lines I use ggrepel but I get all the 4 labels instead of 2 for each graph. How to correct this error? The location of the labels is in this example at the last date but…
sbac
  • 1,897
  • 1
  • 18
  • 31
0
votes
1 answer

ggrepel::geom_text_repel not working in large mode/Rstudio notebook output (nor with cowplot)

I was wondering if anyone knew why this is happening. Here is a quick example of the code and screenshots. library(ggplot2) iris$randomratio <- iris$Sepal.Length/iris$Sepal.Width plot_iris <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color =…
0
votes
1 answer

I can't get my plots to a single grid please help correct my code

I have 11 plots and used a looping function to plot them see my code below. However, I can't get them to fit in just 1 page or less. The plots are actually too big. I am using R software and writing my work in RMarkdown. I have spent almost an…
Nana
  • 1
  • 1
0
votes
1 answer

Remove labels on NULL plots using plot_grid and cowplot

I am using plot_grid and cowplot to arrange plots in a grid. I need to have some "empty" plots in the grid. Using NULL works fine - but the space still gets labelled. Is there a way to make NULL plots have no label automatically? I know I can do…
Esme_
  • 1,360
  • 3
  • 18
  • 30