[R] lattice plotting character woes

Murray Jorgensen maj at stats.waikato.ac.nz
Tue Aug 26 23:34:10 CEST 2008


[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



More information about the R-help mailing list