R ggplot: Remove all space around plot

Viewed 3390

How do I remove all space around the plot area?

Sample data

dfr <- data.frame(x=factor(1:5),y=c(3,5,4,2,4))

ggplot(dfr,aes(x,y))+
  geom_bar(stat="identity")

I tried as below, but there is still space on left and bottom. Bg border colour added to visualise edge.

ggplot(dfr,aes(x,y))+
  geom_bar(stat="identity")+
  labs(x="",y="")+
  theme(axis.ticks=element_blank(),
        axis.text=element_blank(),
        plot.background=element_rect(colour="steelblue"),
        plot.margin=grid::unit(c(0,0,0,0),"cm"))

enter image description here

1 Answers
Related