[R] Lattice xyplot: modify line width of plot lines
    ukoenig at med.uni-marburg.de 
    ukoenig at med.uni-marburg.de
       
    Mon Aug 24 10:47:31 CEST 2009
    
    
  
# Hi all,
# I want to increase the line width of the plotted lines
# in a xy-lattice plot. My own attempts were all in vain.
# Without the group option the line width is modified -
# with the option it is funnily enough not.
# Please have a look at my syntax.
#
# Many thanks in advance
# Udo
############################################################
library(lattice)
data <- data.frame(cbind(1:2,c(1,1,2,2), c(0.5,0.9,1.0,1.8)))
names(data) <- c("BMI","time","Choline")
data$BMI <- factor(data$BMI)
levels(data$BMI) <- c("<=17.5",">17.5")
data$time <- factor(data$time)
levels(data$time) <- c("Admission","Discharge")
#Show names of settings
names(trellis.par.get())
#Try to set the line width of the two plotted colored lines
line<-trellis.par.get("plot.line")
line
line$lwd=3
trellis.par.set("plot.line", line)
line
#Without group option: Line width is changed
xyplot(Choline ~ time,
        data=data,
        type="l",
        scales=list(relation="free"),
        auto.key=list(title="BMI Group", border=FALSE),
        xlab=c("Point in Time"),
        ylab=c("Concentration of Choline"))
#With group option: Line width is not changed
xyplot(Choline ~ time,
        group=BMI,
        data=data,
        type="l",
        scales=list(relation="free"),
        auto.key=list(title="BMI Group", border=FALSE),
        xlab=c("Point in Time"),
        ylab=c("Concentration of Choline"))
    
    
More information about the R-help
mailing list