Plot frame color and linewidth

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Plot frame color and linewidth

marcel
This post was updated on .
I have a figure with a lattice plot and a basic plot. Is there a way to select the color and line width of the surrounding boxes for each of these? I could not find any documentation on this.  

# Data
tC <- textConnection("
Time Type1 Type2 Type3
1.3 .50 .10 .40
4.5 .45 .20 .35
5.2 .40 .30 .30
")

data1 <- read.table(header=TRUE, tC)
data2 <- data.frame(Time=rep(data1$Time, 3), stack(data1[,2:4]))
close.connection(tC)
rm(tC)


#My lattice plot
require(lattice)
plot1<-xyplot(values ~ Time, par.settings = list(layout.widths = list(ylab.axis.padding = 0)), ylab=list(label="Y Label", fontsize=9), scales=list(y=list(relation="free", rot=0, cex=0.7), x = list(draw = FALSE)), group=ind, data=data2, stack=TRUE, horizontal=FALSE, panel=panel.barchart, box.width=0.1, axes=FALSE, ylim=c(0.03,0.98), xlim=c(-0.2, 6.25), main="Lattice Plot", xlab="")
plot(0.1,0.1, axes=FALSE, ylab="", xlab="", pch = "")  # dummy plot to reset basic plot environment
print(plot1, position=c(-0.0068,0.221,0.741,0.466))

#My basic plot
par(new=TRUE, mfrow = c(4, 2), fig=c(0,1,0,1), mar=c(42.9, 4, 1.14, 15))
plot(data1$Time, data1$Type1, frame=T, main="Basic Plot", ylab="Y Label", xlab="", col=2, xlim= c(0,6), ylim= c(0, 1), axes=FALSE)
axis(2, at=c(0.25, 0.5, 0.74), las=1)
Reply | Threaded
Open this post in threaded view
|

Re: Plot frame color and linewidth

Dieter Menne
marcel wrote
I have a figure with a lattice plot and a basic plot. Is there a way to select the color and line width of the surrounding boxes for each of these? I could not find any documentation on this.  
Thanks for providing a nice self-contained example. There was nothing wrong with it, but you can simplyfy your life with:

library(lattice)
xyplot(1~1, par.settings = list(axis.line=list(col="green")))

When lost in trellis space, I always do:

str(trellis.par.get())

For standard graphics, there is an example with gray color at the bottom of the par-help page.

Dieter