I have several plots to draw and save. I want to save the graph popped up in the zoomed window. What I did is as follows (which is normal save):
SaveName <- c("A.pdf", "B.pdf")
Path <- "~"
GroupName <- c("A", "B")
for (i in seq_along(Group)) {
pdf(file = paste(Path, SaveName[i], sep = ""), width = 8, height = 6)
plotA <- ggplot(df %>% filter(Group == GroupName[i]), aes(x, y)) +
geom_point() +
print(plotA)
dev.off()
}
In this way, the files saved are the same as that by clicking "Export" -> "Save as PDF" in Rstudio. If I use the ggsave
function and changes the dpi
argument, it does not help much.
I want to save the graphs with R commands as if I click "Zoom" button, right-click on the picture, and then "Save image as". Can this be done in R?