-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
This StackOverflow question: https://stackoverflow.com/q/72698223 illustrates what looks like a bug in the display of graphics. This script:
temp <- mtcars[, 1:3]
colnames(temp) <- c("x1", "z", "y1")
plotting_function <- function(data_to_vis) {
p1 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
geom_point(size = 3)
options(repr.plot.width = 5, repr.plot.height = 5)
print(p1)
p2 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
geom_point() +
facet_wrap(~z) +
theme(aspect.ratio = 1)
options(repr.plot.width = 20, repr.plot.height = 20)
print(p2)
}
library(ggplot2)
plotting_function(temp)uses the 2nd options() setting to set the width and height of both plots. To get them to appear as intended, the first setting needs to be moved after the print(p1) statement.
This was tested on the R kernel at https://jupyter.org/try, which reports "The version of the notebook server is: 6.4.10", "Current kernel information: R version 4.1.2 (2021-11-01)".
Metadata
Metadata
Assignees
Labels
No labels