Skip to content
Back to formatted view

Raw Message

Message-ID: <9e4dcd06-68b7-5bf5-b4d0-85f2b549abd4@rgzm.de>
Date: 2021-09-14T07:17:37Z
From: Ivan Calandra
Subject: ggsave() with width only
In-Reply-To: <a6477734-fefa-9cba-b7c1-b214858edd83@e.email>

Thank you Adam!

I'm a bit surprised that an extra package is needed for this, but why not!

Best,
Ivan

--
Dr. Ivan Calandra
Imaging lab
RGZM - MONREPOS Archaeological Research Centre
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 13/09/2021 15:40, Adam Wysoki?ski wrote:
> Hi,
> Instead of ggsave(), use save_plot() from the "cowplot" package:
>
> library(ggplot2)
> library(cowplot)
> x <- 1:10
> y <- x^2
> df <- data.frame(x, y)
> p <- ggplot(df, aes(x, y)) + geom_point()
> save_plot("/tmp/plot.png", p, base_aspect_ratio = 1, base_width = 5, 
> base_height = NULL)
>