Dear plotting wizards, when plotting in R, the actual lengths of the axes are slightly greater than the ranges of the x/y variables or xlim/ylim values. how do I control the amount by which the axes are enlarged? Is there a way to enforce that the lengths of the axes equal xlim/ylim? example: plot(0:100,0:100,pch="+") it can be observed, that the x- and y-axis join at approx. (-4,-4) and (104,104). If I want the axes to join at (0,0) and (100,100) I have to cheat R into doing it by providing wrong xlim/ylim values: plot(0:100,0:100,pch="+",xlim=c(4,96),ylim=c(4,96)) is there a proper way to control this? I've been reading through the help for "par" but I still have no clue. Any help appreciated. Thanks, Peter
Peter Neuhaus wrote:> Dear plotting wizards, > > when plotting in R, the actual lengths of the axes are slightly > greater than the ranges of the x/y variables or xlim/ylim values. > > how do I control the amount by which the axes are enlarged? Is > there a way to enforce that the lengths of the axes equal > xlim/ylim? > > example: > > plot(0:100,0:100,pch="+") > > it can be observed, that the x- and y-axis join at approx. (-4,-4) > and (104,104). If I want the axes to join at (0,0) and (100,100) > I have to cheat R into doing it by providing wrong xlim/ylim values: > > plot(0:100,0:100,pch="+",xlim=c(4,96),ylim=c(4,96)) > > is there a proper way to control this? I've been reading through > the help for "par" but I still have no clue. >If you use xaxs="i" in your call, the axes won't be extended. If you want them extended by something other than the default amount, you should probably use both xaxs="i" and xlim=... for fine control. Duncan Murdoch
On 05/26/2010 09:49 PM, Peter Neuhaus wrote:> Dear plotting wizards, > > when plotting in R, the actual lengths of the axes are slightly > greater than the ranges of the x/y variables or xlim/ylim values. > > how do I control the amount by which the axes are enlarged? Is > there a way to enforce that the lengths of the axes equal > xlim/ylim? > > example: > > plot(0:100,0:100,pch="+") > > it can be observed, that the x- and y-axis join at approx. (-4,-4) > and (104,104). If I want the axes to join at (0,0) and (100,100) > I have to cheat R into doing it by providing wrong xlim/ylim values: > > plot(0:100,0:100,pch="+",xlim=c(4,96),ylim=c(4,96)) > > is there a proper way to control this? I've been reading through > the help for "par" but I still have no clue. >Hi Peter, See par("xaxs") and par("yaxs") for the answer "i". You are correct about the expansion provided by the default "r" style. Jim