I would like to remove the white border in a .png output file, using ggplot2
.
I'm using Windows 10 with Rstudio, ggplot2
, and geom_raster
. After spending time searching on forums, and playing with some parameters, I ended up with this codes (that still does not work):
library(ggplot2)
library(datasets)
png(file = "Out.png")
par(mar=rep(0, 4), plt=c(0.1,0.9,0.1,0.9), xpd=NA)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density))+
theme(axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.margin = unit(0,"null"),
legend.position = "none",
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_blank(),
plot.margin = rep(unit(0,"null"),4))
dev.off()
This code gives this png: