I am trying to save a scatterplot that looks nice in RStudio but is not working when I am saving it in a loop with ggsave() or png(). I tried changing the width and the height but it is not working
saved from the plot in Rstudio
for (i in traits) {
scatter<- ggplot(datos, aes(x = TREATMENT, y = i,
label = ifelse(TREATMENT %in% checks, TREATMENT, ""), size = 0.4)) +
geom_text_repel(size = 2,
point.padding = 0.2,
nudge_x = 0.05,
nudge_y = 0,
segment.curvature = 0, max.overlaps = Inf,
arrow = arrow(length = unit(0.015, "npc"))) +
geom_point(aes(color = pop), size = 1, na.rm = T) +
theme_classic() +
scale_colour_brewer(palette = "Set1")
png(file = paste0("images/01_scatterplot_raw", i, ".png"), width = 720, height = 720)
print(scatter)
dev.off()
}