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

How to add x label in multiple histograms quickly in R

I see this code : list <-lapply(1:ncol(mtcars), function(col) ggplot2::qplot(mtcars[[col]], geom = "histogram",binwidth = 1)) cowplot::plot_grid(plotlist = list) surggest by Paul Endymion to respond to "Plotting multiple histograms quickly in R". I…
1
vote
1 answer

Legend inscription above the legend

I have a rather specific problem for which I am currently looking for a solution and cannot find one. I would like to create a legend with ggplot where the caption of the legend is below the legend - I don't know how to explain it better. I'm sure…
LePyka
  • 181
  • 8
1
vote
1 answer

font_add_google altering spacing and alignment when using plot_grid and saving

I am making a plot and using a custom from Google using the {sysfonts} package. In order for this to run, I also have to run showtext_auto from the {showtext} package. Whenever I use the new font with geom_richtext() function from the {ggtext}…
OKLM
  • 85
  • 7
1
vote
2 answers

Automatic scaling of text size

I am trying to figure out how to make the text size of a text variable based on its length. I don't know how to explain it better :D I have a text field where a user can enter text. I want the text to always be the "maximum possible" size in a…
LePyka
  • 181
  • 8
1
vote
2 answers

Removing empty space from ggplot after coord_fixed is used

I am trying to plot three different plots together to form a larger figure. The problem is that plot.margin(c(0,0,0,0), "cm") doesn't remove the whitespace as expected. The figures are close together as expected if I remove the coord_fixed. Example…
MesRot
  • 133
  • 1
  • 9
1
vote
1 answer

draw_image distorts png in plot and output

I am currently trying to display some PNGs using the "draw_image" function. To be more precise, these are certain emojis. As soon as I load the PNGs via draw_image, they are unfortunately distorted, so that the emojis look like this: But of course…
LePyka
  • 181
  • 8
1
vote
0 answers

cowplot, ggplot; how to align vertically two plots

I'm trying yo aling vertically two plots with cowplot but I can't and I don't know why: Code: manufac_count <- mpg %>% count(manufacturer) %>% mutate(ymax = cumsum(n), ymin = lag(ymax, n = 1, default = 0)) model_count <- mpg %>% …
1
vote
1 answer

ggplot, cowplot; Scatterplot with marginal histograms: axes do not match

I'm looking for a way to create a scatterplot with marginal histograms. I found a solution using ggplot2 + cowplot (thanks @crsh): library(ggplot2) library(cowplot) # Set up scatterplot scatterplot <- ggplot(iris, aes(x = Sepal.Length, y =…
1
vote
1 answer

Align a shared legend in cowplot

I'm looking to use the cowplot package to give two ggplots a shared legend. However, how can I center the shared legend when there's an even number of plots. Here's some example code: library(ggplot2) library(cowplot) library(rlang) # down-sampled…
1
vote
1 answer

Creating the same scale for graphs with different scales

I have a data set where I created ggplots for each ind where I end up with four different graphs. I had put these graphs into a list, and then used plot_grid from cowplot to get a single output that displays all four graphs at once. I'm not quite…
John Huang
  • 845
  • 4
  • 15
1
vote
1 answer

Align vertical 3 plots in 2 rows in cowplot package in R

I would like to align vertical plot from row 1 and plot from row 2. It didn't matter how hard I try, but it did not let me align. Any ideas? library(dplyr) library(forcats) library(ggplot2) library(cowplot) city_mpg <- mpg %>% mutate(class =…
Ben
  • 181
  • 6
1
vote
1 answer

How to convert qgraph plot to grob or otherwise produce a single plot with several qgraph objects?

I would like to create a single figure with multiple panels, in which each panel contains a qgraph network plot. Ideally, I would do this: pacman::p_load(qgraph) # Load big5 dataset: data(big5) data(big5groups) # Correlations: Q <-…
ethanweed
  • 33
  • 7
1
vote
1 answer

Use plot_grid to arrange plots where plot information is stored in an R data frame

I generate a series of plots stored in a matrix as part of a for loop much like in the MWE below. This same matrix also stores two other columns of information (Colour and Animal in this example). I then want to be able to create a grid of…
Esme_
  • 1,360
  • 3
  • 18
  • 30
1
vote
2 answers

Use checkboxGroupInput in Shiny to make selectable plots from one tibble with plot_grid

I'm trying to make a Shiny app which will take an uploaded CSV file and convert it into a tibble and then make a series of plots with the same X but using different columns for Y data, one per plot. I want the user to be able to use check boxes to…
Savok
  • 13
  • 4
1
vote
1 answer

R Plot Bars are disappearing in grid.arrange/plot_grid

I have a problem with bars from my plots disappearing when I combine multiple plots. Here is the code I´m using: station<-c("Eins", "Zwei", "Drei","Vier") x1<-c(200, 185,…