[R] Problems with lattice plot
Jim Lemon
jim at bitwrit.com.au
Sat Jan 19 11:51:40 CET 2008
Francesc Montané wrote:
> Hello useRs,
>
>
>
> I have some problems when I try to plot a lattice. The lattice has 200
> columns (X value) and 5 rows (Y value), with a total of 1000 squares. I
> want to plot this lattice with the squares having different colours
> according to a variable value.
>
>
>
> The variable I want to plot is cover value of a shrub, and it has values
> between 0 and 1. I want to plot the squares with value 1, black, the
> squares with values 0, white, and the values between 0 and 1 with grey,
> more or less dark depending on its proximity to 1 (dark grey) or 0
> (light grey). I have tried this:
>
>
>
> plot(x=transect41$x,y=transect41$y,asp=1,
>
> xlab="",ylab="",
>
> axes=F,pch=22,cex=1.01,lwd=0.05,
>
> bg=gray(1-transect41$CoverValue),col=gray(0.75))
>
> plot(pch=22,cex=1.01,lwd=0.05)
>
>
>
> When I plot the lattice, I have problems because the squares have
> different sizes. Moreover, some of them look like a rectangle and not a
> square.
>
> What can I do to solve this problem?
>
Hi Francesc,
Try this:
library(plotrix)
transect<-matrix(runif(1000),nrow=5)
x11(width=14,height=2.4)
color2D.matplot(transect,c(1,0),c(1,0),c(1,0),
main="Shrubbery",show.legend=TRUE)
You will probably have to fiddle the device width/height a bit to get
squares.
Jim
More information about the R-help
mailing list