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
5
votes
2 answers

grid_plot + tikzDevice + shared legend with latex mark up

I've been trying to follow this vignette on how to make a shared legend for multiple ggplot2. The given examples work perfectly as is, but in my case, I'm using tikzDevice to export a tikzpicture environment. The main problem seems to be that the…
5
votes
2 answers

for loop with ggplots produces graphs with identical values but different headings

I have read lots of posts about using loops for ggplot to generate lots of graphs, but cannot find any that explain my problem... I have a dataframe and am trying to loop over 92 columns, creating a new graph for each column. I want to save each…
Harry
  • 65
  • 1
  • 5
5
votes
1 answer

Left-aligned axis labels when using cowplot to switch x axis to top

I'm trying to make a correlation heatmap where the x axis is moved to the top using cowplot::switch_axis_position. I have axis labels of varying length and I want the labels to be left-aligned (or rather bottom-aligned, because they are rotated 90…
Esther
  • 441
  • 2
  • 15
4
votes
0 answers

How to save a plot exactly same as it appears in Rstudio?

I have plotted an image using ggplot & then combined it with some pics/logos using cowplot + magick. Issue is on saving the plot using ggsave() image doen't save as it looked in the editor and gets misaligned with respect to pics/logos combined with…
ViSa
  • 1,563
  • 8
  • 30
4
votes
1 answer

Cowplot plot_grid() : Title in plot

I am trying to include a title in an assembled graph built using plot_grid(). I tried both the solution proposed in the cowplot reference guide here by @Claus Wilke, and the workaround suggested here as part of the questions itself (extracting the…
Filippo Santi
  • 109
  • 1
  • 8
4
votes
1 answer

Split axis plot in ggplot2

I just found this plot in Factfulness (book by Hans Rosling and his children). I find the aestetics of the split quite appealing. While it's possible to make something similar using geom_rect(), it's a quite different look. Another approach would…
Matias Andina
  • 4,029
  • 4
  • 26
  • 58
4
votes
1 answer

align ggplot map plots with coord_equal()

I am having trouble aligning two maps. I am using a reproducible example below: library(ggplot2) library(cowplot) world <- map_data("world") pl2= ggplot() + geom_polygon(data=world, aes(x=long, y=lat, group=group)) + theme_bw()+ …
yuliaUU
  • 1,581
  • 2
  • 12
  • 33
4
votes
1 answer

How to combine a graph generated with igraph and a plot made with ggplot2 by means of cowplot::plot_grid

Initially, I could not plot it completely, meaning that I could not find a way to capture the plot object and feed it to cowplot::plot_grid. Now, I found a workaround which saves to file the image of the graph plot as png and read it with…
Garini
  • 1,088
  • 16
  • 29
4
votes
1 answer

How to plot an aligned text on severals lines / colomns?

I am creating a "page" via several lines and columns with aligned text (left/right/top/bottom). I would like to use the grid.arrange() function but I can't do it. I read in an old post that the grid_plot() function does the job. So my code is #…
Eric
  • 41
  • 2
4
votes
1 answer

Incorrect colour gradient when using cowplot to patch together plots

Say I have a data set with x and y values that are grouped according to two variables: grp is a, b, or c, while subgrp is E, F, or G. a has y values in [0, 1] b has y values in [10, 11] c has y values in [100, 101]. I'd like to plot y against x…
Dan
  • 11,370
  • 4
  • 43
  • 68
4
votes
2 answers

Cowplot clips labels when plotted with y >1 on multiple plots

First, some mock graphs: df <- data.frame(x = 1:10, y = 2:11) Because my real graphs are fairly complicated, I'm going not going to provide them here, but will use other graphs that reproduce the problem. Suffice it to say that when align is set to…
Grubbmeister
  • 857
  • 8
  • 25
4
votes
1 answer

Convert base plot to grob, keeping aspect ratio

I need to convert an R base plot to a grob, so it can be superimposed over some ggplots. There are a couple of functions for doing this that I've found, ggplotify::as.grob and cowplot::plot_to_gtable. The trouble is, they don't preserve the aspect…
Bob
  • 1,274
  • 1
  • 13
  • 26
4
votes
1 answer

The draw_image() function from cowplot results in blurred pdfs

Reading a vectorized pdf sometimes result in a badly blurred image with the draw_image() function from cowplot: library(ggplot2) library(cowplot) library(magick) # make pdf input as example p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, shape =…
user7727736
  • 97
  • 1
  • 8
4
votes
3 answers

How to save plots in R and have them nice looking

I'm trying to make a plot in R with some data and a table beneath it. In R, it looks good (Picture 1), however, when I export the picture (Picture 2), it looks really ugly and is not in same format. library(tidyverse) library(cowplot) p <-…
MLEN
  • 2,162
  • 2
  • 20
  • 36
4
votes
1 answer

Aligning facetted plots and legends

I'm trying to plot facets with each facet having its own legend. However, I am having some trouble to get it all aligned properly. dat <- structure(list(group1 = structure(c(1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), group2 =…
erc
  • 10,113
  • 11
  • 57
  • 88
1 2
3
18 19