[R] lattice plotting character woes
Murray Jorgensen
maj at stats.waikato.ac.nz
Tue Aug 26 08:50:57 CEST 2008
Hi Rolf, Hi Mark, Hi List,
I have not digested Rolf's response yet. It may well answer my problems.
In the meantime I have some reproducible code which actually shows my
problem:
patches <-
structure(list(URBAN_AREA = structure(c(2L, 19L, 23L, 2L, 19L,
23L, 2L, 19L, 23L, 2L, 19L, 23L), .Label = c("CENTRAL AUCKLAND ZONE",
"CHRISTCHURCH", "DUNEDIN", "HAMILTON ZONE", "HASTINGS ZONE",
"INVERCARGILL", "LOWER HUTT ZONE", "mean", "NAPIER ZONE", "NELSON",
"NEW PLYMOUTH", "NORTHERN AUCKLAND ZONE", "PALMERSTON NORTH",
"PORIRUA ZONE", "ROTORUA", "SD", "SE", "SOUTHERN AUCKLAND ZONE",
"TAURANGA", "WANGANUI", "WELLINGTON ZONE", "WESTERN AUCKLAND ZONE",
"WHANGAREI"), class = "factor"), NO_PATCHES = c(11L, 16L, 21L,
87L, 192L, 324L, 164L, 417L, 773L, 679L, 757L, 3083L), MEAN_AREA =
c(9.623631225,
15.29089619, 149.2063532, 14.1676, 247.5262, 28.611, 11.5698,
221.0022, 37.3725, 11.918, 133.5804, 25.6759), AREA.ZONE = c(13683,
3666, 1558, 64830, 41103, 22581, 123819, 90107, 57627, 264735,
223963, 174456), Buffer.zone = c(0L, 0L, 0L, 5L, 5L, 5L, 10L,
10L, 10L, 20L, 20L, 20L)), .Names = c("URBAN_AREA", "NO_PATCHES",
"MEAN_AREA", "AREA.ZONE", "Buffer.zone"), class = "data.frame",
row.names = c(2L,
15L, 19L, 22L, 36L, 40L, 42L, 56L, 60L, 62L, 76L, 80L))
library(lattice)
Region = factor(patches$URBAN_AREA)
lpatches = patches
for (i in 2:4) lpatches[,i] = log10(patches[,i])
# zone not transformed
lpatches.pca = princomp(lpatches[,-c(1,17)],cor=FALSE)
x = lpatches.pca$scores[,1]
y = lpatches.pca$scores[,2]
zz = as.character(patches$Buffer.zone/5)
table(zz)
plsy <- trellis.par.get("plot.symbol")
# only 0 or 1 used as plotting symbol
plsy$pch = as.character(rep(1:6,2))
trellis.par.set("plot.symbol",plsy)
xyplot(y ~ x |Region)
# only 1,2,3,4 used as plotting symbol
I actually wish 0,1,2, or 4 to be used - to indicate the zone coded in zz.
Cheers, Murray
PS The xyplots produced on R 2.7.0 for Mac OS X, the first one also on
an older Windows version.
Rolf Turner wrote:
>
>
> Murray:
>
> I'm not at all sure that I understand what you're driving at --- but
> does this do something like what you want?
>
> require(lattice)
> set.seed(260808)
> n = 50
> x = rnorm(n)
> y = rnorm(n)
> z = ceiling(runif(n,0,4))
> g = runif(n,0,6)
> G = factor(ceiling(g))
> print(xyplot(y ~ x | G,pch=G,
> panel=function(x,y,...,subscripts,pch) {
> panel.xyplot(x,y,pch=pch[subscripts])
> }
> ))
>
>
> cheers,
>
> Rolf
>
> ######################################################################
> Attention: This e-mail message is privileged and confidential. If you
> are not the intended recipient please delete the message and notify
> the sender. Any views or opinions presented are solely those of the
> author.
>
> This e-mail has been scanned and cleared by MailMarshal
> www.marshalsoftware.com
> ######################################################################
--
Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz majorgensen at ihug.co.nz Fax 7 838 4155
Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 139 5862
More information about the R-help
mailing list