Alaios wrote on 01/09/2012 10:28:28 AM:
> Dear all,
> I would like to tell plot to limit the plotted area into values (for
> the x axis) that are from X1 to X2.
> I have tried to use xlim=c(X1,X2) inside plot.. but unfortunately
> this does only change the labeling of the xaxis and not the values
> plotted there.
>
> How I can do that in R?
>
> B.R
> Alex
Without a more concrete example, I'm not exactly sure what you're after.
Here are a few examples of plots given different arguments to the plot()
function. Perhaps one of them is doing what you want.
x <- 100*runif(100)
y <- 100*runif(100)
X1 <- 23
X2 <- 71
sel <- x >= X1 & x <= X2
par(mfrow=c(2, 2))
plot(x, y, main="plot(x, y)")
abline(v=c(X1, X2), lty=2, col="red")
plot(x, y, xlim=c(X1, X2), main="plot(x, y, xlim=c(X1, X2))")
abline(v=c(X1, X2), lty=2, col="red")
plot(x[sel], y[sel], main="plot(x[sel], y[sel])")
abline(v=c(X1, X2), lty=2, col="red")
plot(x[sel], y[sel], xaxs="i", main='plot(x[sel], y[sel],
xaxs="i")')
abline(v=c(X1, X2), lty=2, col="red")
Jean
[[alternative HTML version deleted]]