1

I would like to save a plot, without any whitespace around the plot area.

Example of Problem

I have tried this code, but still have whitespace to left of yaxis, and below xaxis.

library(ggplot2)
    ggplot(data.frame(x=c(1,1,2,2),y=c(1,2,2,1)), aes(x, y)) +
    geom_polygon(fill="grey75") +
    geom_point(size=50,colour="yellow") +
    theme( 
    legend.position = "none",
    panel.background = element_blank(),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    panel.margin = unit(0,"null"),
    plot.margin = rep(unit(0,"null"),4),
    axis.ticks = element_blank(),
    axis.text.x = element_blank(),
    axis.text.y = element_blank(),
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    axis.ticks.length = unit(0,"null"),
    axis.ticks.margin = unit(0,"null"))+
    scale_x_continuous(expand=c(0,0)) + 
    scale_y_continuous(expand=c(0,0))][1]][1]
user1375871
  • 1,199
  • 1
  • 12
  • 23

0 Answers0