[R] Lattice xyplot: modify line width of plot lines
Chuck Cleland
ccleland at optonline.net
Mon Aug 24 11:00:39 CEST 2009
On 8/24/2009 4:47 AM, ukoenig at med.uni-marburg.de wrote:
> # 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
You need to change the superpose.line setting:
xyplot(Choline ~ time,
groups=BMI,
data=data,
type="l",
scales=list(relation="free"),
auto.key=list(title="BMI Group",
border=FALSE, lines=TRUE, points=FALSE),
xlab=c("Point in Time"),
ylab=c("Concentration of Choline"),
par.settings = list(superpose.line = list(lwd=3)))
> ############################################################
>
> 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"))
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list