[R] lattice plot axis scaling

Alan S Barnett asb at mail.nih.gov
Wed Jul 18 20:23:10 CEST 2007

I want to generate a lattice plot of a multiple linear regression.  I'm
using the code:

xyplot(y ~ x1 + x2 | status, data=datam,
        xlab="Peak separation",ylab="G/W",main="G/W vs Fuzzy peak
separation: Threshold=1.8",
	subset=(status %in%  c("control","patient","sibling")),
          panel.abline(tmp<<-lm(y~x),col = "light blue",lwd=2)
          panel.abline(tmp<<-rlm(y~x),col = "blue",lwd=2)
          fm <- rlm(y[good.id] ~ x[good.id])
          sm <- summary(fm)
          panel.abline(reg = fm)
          panel.abline(tmp1<<-lm(y[good.id]~x[good.id]),col =
          panel.abline(tmp1<<-rlm(y[good.id]~x[good.id]),col =
          slope <- round(coef(fm)[2], 3)
          err <- round(sm$coefficients[4], 3)
          message("Click on desired location")
          panel.text(pos<<-grid.locator("native"), lab = paste("slope
The problem is that x1 varies from 1-3, while x2 varies from 20-60.  The
output scales both independent variables the same, so all the data in
the y vs x1 plot are up against the left edge of the plot.  How do I
scale the x-axes separately?

More information about the R-help mailing list