Remove spacing around plotting area in r

前端 未结 2 965
既然无缘
既然无缘 2020-12-13 00:28

When I create the following plot I get unwanted space between the plotting area and the axis (i.e. the white space between the blue box and the x axis. How can I remove this

相关标签:
2条回答
  • 2020-12-13 01:08
    plot(c(1,2.75),c(1,2.75),type="n",main="title",xlab="site.x",ylab="ylab",axes=F) # ann
    axis(1,pos=1)
    axis(2,pos=1)
    

    All axes are remove then you can add new axes to the pos you want.

    0 讨论(0)
  • 2020-12-13 01:29

    There is an argument in function plot that handles that: xaxs (and yaxs for the y-axis). As default it is set to xaxs="r" meaning that 4% of the axis value is left on each side. To set this to 0: xaxs="i". See the xaxs section in ?par for more information.

    plot(c(1,2.75),c(1,2.75),type="n",main="title",xlab="site.x",ylab="ylab", xaxs="i", yaxs="i")
    rect(xleft,ybottom,xright,ytop,col=c("blue","red","green"))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题