[R] ggsave() with width only

Ivan Calandra c@|@ndr@ @end|ng |rom rgzm@de
Mon Sep 6 16:29:34 CEST 2021

Thank you Jeff for your answer.

I do use rmarkdown but I do not write papers completely with it. I do 
output a report in HTML but I also like to export the plots as PDF so 
that I can edit them (using Inkscape or similar) if and as needed.
And because I like to have both the HTML report including plots and 
extra plots as PDF, I cannot use pdf(). That's why I use ggsave().

Or am I missing something?


Dr. Ivan Calandra
Imaging lab
RGZM - MONREPOS Archaeological Research Centre
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243

On 06/09/2021 16:24, Jeff Newmiller wrote:
> I use an rmarkdown file to generate consistent output figures and tables for html or Word. I just use Rnw files directly if I am generating LaTeX. I do not use R files for building output... and I never use ggsave. So you might consider altering your approach to bypass the question entirely.
> On September 6, 2021 7:03:46 AM PDT, Ivan Calandra <calandra using rgzm.de> wrote:
>> Dear useRs,
>> I produce several independent ggplot2 plots and I would like to save
>> them to a fixed width (for publications), but the height (and therefore
>> aspect ratio) is different from plot to plot.
>> How can I save my plots with ggsave() supplying only a fixed width but
>> without knowing the height nor the aspect ratio? If I specify the width
>> only, the plots are truncated in width because the aspect ratio is not
>> correct.
>> Thank you for the tip!
>> Ivan

More information about the R-help mailing list