The following reproducable code shows the setting of my problem: 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)) xyplot(y ~ x | G) plsy <- trellis.par.get("plot.symbol") plsy$pch = z trellis.par.set("plot.symbol",plsy) xyplot(y ~ x | G) plsy$pch = as.character(z) trellis.par.set("plot.symbol",plsy) xyplot(y ~ x | G) Unfortunately it does not reproduce the problem, which is that instead of the plotting characters being determined by the value of G, they are all the same, corresponding to the lowest level of G. Here is my actual output: > patches = read.csv(apf,header=TRUE) > summary(patches) X URBAN_AREA NO_PATCHES MEAN_AREA Mode:logical CENTRAL AUCKLAND ZONE: 4 Min. : 0.0 Min. : 0.00 NA's:83 CHRISTCHURCH : 4 1st Qu.: 81.5 1st Qu.: 11.64 DUNEDIN : 4 Median : 200.0 Median : 23.19 HAMILTON ZONE : 4 Mean : 375.5 Mean : 323.08 HASTINGS ZONE : 4 3rd Qu.: 524.5 3rd Qu.: 149.54 INVERCARGILL : 4 Max. :3083.0 Max. :6609.34 (Other) :59 NA's : 3.00 MAX_AREA MIN_AREA STD_AREA MEAN_EDGE Min. :1.008e+01 Min. :0.0029 Min. : 3.115 Min. : 1075 1st Qu.:1.716e+02 1st Qu.:0.1605 1st Qu.: 24.939 1st Qu.: 1867 Median :2.336e+03 Median :0.2516 Median : 185.198 Median : 2669 Mean :6.211e+04 Mean :0.5888 Mean : 3888.733 Mean : 6584 3rd Qu.:3.670e+04 3rd Qu.:0.4713 3rd Qu.: 2148.932 3rd Qu.: 6149 Max. :1.449e+06 Max. :8.8260 Max. :64028.083 Max. :94641 NA's :4.000e+00 NA's :4.0000 NA's : 4.000 NA's : 4 MAX_EDGE MIN_EDGE STD_EDGE MEAN_E_A Min. : 2340 Min. : 34.35 Min. : 290.2 Min. :0.01491 1st Qu.: 20369 1st Qu.: 162.04 1st Qu.: 2919.3 1st Qu.:0.03320 Median : 124243 Median : 193.47 Median : 9182.8 Median :0.03910 Mean : 841731 Mean : 286.33 Mean : 53940.9 Mean :0.03924 3rd Qu.: 913745 3rd Qu.: 325.62 3rd Qu.: 56914.0 3rd Qu.:0.04527 Max. :13086956 Max. :1770.00 Max. :584281.0 Max. :0.06010 NA's : 4 NA's : 4.00 NA's : 4.0 NA's :4.00000 MAX_E_A MIN_E_A STD_E_A AREA.ZONE Min. :0.01755 Min. :0.000900 Min. :0.002378 Min. : 1114 1st Qu.:0.08890 1st Qu.:0.001526 1st Qu.:0.016550 1st Qu.: 13996 Median :0.10146 Median :0.002900 Median :0.018500 Median : 38015 Mean :0.14431 Mean :0.005689 Mean :0.019567 Mean : 60883 3rd Qu.:0.12040 3rd Qu.:0.008592 3rd Qu.:0.020784 3rd Qu.: 84787 Max. :1.20530 Max. :0.024350 Max. :0.059000 Max. :264735 NA's :4.00000 NA's :4.000000 NA's :4.000000 NA's : 3 No..patches.100.ha X.1 Buffer.zone Min. :0.0000 Mode:logical Min. : 0.000 1st Qu.:0.3534 NA's:83 1st Qu.: 5.000 Median :0.5653 Median :10.000 Mean :0.6952 Mean : 9.157 3rd Qu.:0.9080 3rd Qu.:20.000 Max. :2.9374 Max. :20.000 > # clean > patches = patches[,-c(1,18)] > patches = patches[-c(20,81,82,83),] > cnames = patches[,1] > acn = abbreviate(cnames) > zone = patches[,17]/5 > names(acn) = NULL > Region = factor(acn) > lpatches = patches > for (i in 2:16) 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) > plsy <- trellis.par.get("plot.symbol") > plsy$pch = zz > trellis.par.set("plot.symbol",plsy) > xyplot(y ~ x |Region) > table(zz) zz 0 1 2 4 19 20 20 20 I would dearly like to have my plotting symbols indicate the zone but I am frustrated. Curiously I may put other (numeric or character) variable in place of zz and get variable plotting characters. Murray -- 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 Fax 7 838 4155 Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 1395 862
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
[Rolf, this crosses with your reply. I will look at your email next.] I pasted the wrong code last time. The following code is supposed to illustrate my problem with lattice plotting character changes. 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 # I expected 0,1,2,4 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 expected 1:6 Mark Leeds has pointed out that whatever numbers appear as plotting characters on the screen, they are replaced by circles when you save a pdf via pdf() xyplot() dev.off() I have reproduced this on my Mac. Cheers, Murray -- 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