Apologies, this is not a fully reproducible example but should hopefully convey the gist of my problem using the current approach. I (try to) use the following code in a Jupyter notebook to print several graphs with different sizes:
#reporducible data
temp <- mtcars[, 1:3]
colnames(temp) <- c("x1", "z", "y1")
plotting_function <- function(data_to_vis) {
options(repr.plot.width = 5, repr.plot.height = 5)
p1 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
geom_point(size = 3)
print(p1)
options(repr.plot.width = 20, repr.plot.height = 20)
p2 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
geom_point() +
facet_wrap(~z) +
theme(aspect.ratio = 1)
print(p2)
}
library(ggplot2)
plotting_function(temp)
Using:
options(repr.plot.width = 5, repr.plot.height = 5)
usually works fine but not in this use case - it is not adhered to - the first graph p1 is printed using:
options(repr.plot.width = 20, repr.plot.height = 20)
Maybe there is a better approach for this use case?