Dear Adam,
This would work indeed, but then the default aspect ratio (1.618) would
be used. I could as well calculate the height from the width and aspect
ratio. Unfortunately, this doesn't help me in my case (but as I said, I
have found a workaround).
Thank you again.
Ivan
--
Dr. Ivan Cal
Dear Ivan,
I think you don't need to provide the aspect ratio, as this should work
as well:
save_plot("/tmp/plot.png", p, base_width = 5, base_height = NULL)
--
Regards,
Adam Wysokiński
On 9/20/21 16:09, Ivan Calandra wrote:
Dear Adam,
The function cowplot::save_plot() actually doesn't help
Dear Adam,
The function cowplot::save_plot() actually doesn't help in my case
because I need to know the aspect ratio (which I don't in advance). If I
knew the aspect ratio, I could calculate the height from the width or
vice-versa, and then I could use ggplot2::ggsave().
I have found a work
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
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)
--
Regards,
Adam W
On 06/09/2021 11:06 a.m., Ivan Calandra wrote:
Yes Jeff, you are right. I hate manually editing figures too, but
sometimes I find it's still the easiest way (e.g. when you submit your
paper several times when journals have differing guidelines, or when you
build figures from several (sub)plots +
Yes Jeff, you are right. I hate manually editing figures too, but
sometimes I find it's still the easiest way (e.g. when you submit your
paper several times when journals have differing guidelines, or when you
build figures from several (sub)plots + other images, or when you
combine plots that
I don't always use rmarkdown to write papers either, but you can capture
figures from it. I avoid hand editing figures like the plague of
irreproducibility. But sometimes you get stuck in an approach... I cannot
answer your original post, but wanted to point out that it may not actually be
nece
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 includin
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
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 he
11 matches
Mail list logo