plot - How can I remove the strange white margin around my .png (plotted with r, ggplot)? -
i save plots ggplot .png. background has black, there allways small white margin (only top, down left; not right).
how can remove margin?
thank you!
here code
library(ggplot2) require(grid) dat <- data.frame("xvar"=runif(500, 1, 10), "yvar"=runif(500, 1, 10)) n <- 1 for(i in 1:n){ png(file=paste("green", i, ".png", sep=""), width=400, height=400) x <- sample(500, 50) <- ggplot(data=dat[x,], aes(x=xvar, y=yvar))+ geom_point(col="green", size=3,shape=15)+ theme(panel.background=element_rect(fill="black"), panel.grid.minor=element_blank(), panel.grid.major=element_blank(), axis.text.x=element_blank(), axis.text.y= element_blank(), axis.title.x=element_blank(), axis.title.y=element_blank(), axis.ticks=element_blank(), plot.background=element_rect(fill="black"), panel.margin = unit(c(0,0,0,0), "cm"), plot.margin = unit(c(0,0,0,0), "cm"))+ scale_x_continuous() print(i) dev.off() }
the line seeing default outline colour of plot.background
rectangle element. can remove setting colour na in theme()
call:
theme(plot.background=element_rect(fill="black", colour=na))
Comments
Post a Comment