[R] control of scat1d tick color in plot.Predict?

Frank E Harrell Jr f.harrell at vanderbilt.edu
Wed Jan 27 16:07:49 CET 2010


Mike Babyak wrote:
> Hi All,
> 
> I have a quick question about using plot.Predict now that the rms package
> uses lattice.  I'd like to add tick marks along the regression line, which
> is given by data=llist(variablename) in the plot call.  The ticks show up
> fine, but I'd like to alter the color.  I know the ticks are produced by
> scat1d, but after spending a fair bit of time going through documentation,
> it still isn't clear to me how to do this in the context of lattice.
> Guidance would be greatly appreciated.
> 
> Thanks,
> 
> Mike Babyak
> Duke University Medical Center
> 
> My code using R 2.10.1/windows XP
> 
> myx<-c(1,2,3,4)
> myy<-c(1,2,3,5)
> 
> library(rms)
> 
> d<-datadist(myx)
> options(datadist="d")
> 
> myfit<-ols(myy~myx,x=T,y=T)
> 
> p1<-Predict(myfit,myx =.)
> 
> library(lattice)
> 
> #change line to black
> line <- trellis.par.get("plot.line")
> line$col <- 1
> trellis.par.set("plot.line", line)
> 
> plot(p1, data=llist(myx),col.fill="lightgray", lwd=1.5)

That's a good request.  I've added a new argument scat1d.opts to 
plot.Predict in rms.  Default is list(frac=0.025, lwd=0.3) with col 
computed.  If you specify col inside the list, it will be used. 
source('http://biostat.mc.vanderbilt.edu/tmp/plot.Predict.s') to get the 
new version.

Frank

-- 
Frank E Harrell Jr   Professor and Chairman        School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list