Reputation: 10735
I have a specific problem in R, which consists in plotting text at specific cartesian coordinates over the plot. However, I cannot seem to eliminate completely the outer margin from the R plotting canvas.
E.g. while trying this code:
par(mar=c(0,0,0,0),oma=c(0,0,0,0))
n=100
plot(0,xaxt='n',yaxt='n',bty='n',pch='',ylab='',xlab='',xlim=c(1,n),ylim=c(0,10))
text(
x=c(1:n),
y=rep(5,n),
srt=90,
labels=paste(1:n),
offset=0
)
Ther is always some empty space to the left of the first number and to the right of the last number. Is there any way to tell the plot() to please not add any empty space around the plotting area?
Any clue will be most appreciated :-) Thanks so much!
Federico
Upvotes: 3
Views: 82
Reputation: 226182
Setting par(xaxs="i")
in addition to your other parameter settings appears to do the job (actually, it cuts off the first and last numbers in the middle, but perhaps you can tweak something to avoid that).
From ?par
:
'xaxs': ... Style "i" (internal) just finds an axis with pretty labels that fits within the original data range.
Upvotes: 5