Sundar suggested setting up a theme which I have done...
my.theme <- function() {
theme <- col.whitebg()
symb <- theme$superpose.symbol
symb$col= c("red","blue","green","yellow","orange","black","purple")
#symb$pch is c(1,3,6,0,5,16,17) by default for col.whitebg
theme$superpose.symbol <- symb
theme
}
trellis.par.set(theme = my.theme())
# from ?dotplot
dotplot(sporder ~ cvarorder | direct, data=sp.nc.bdrs.data,
groups = sp.nc.bdrs.data$mysign,
cex=abs(sp.nc.bdrs.data$mwZ * 0.05),
xlab="climate variables",
ylab="species",
scales = list(y = list(labels = as.character(spname),at = 1:12, cex = 0.5),
x = list(labels = as.character(my.ylabel), at = 1:66, rot=90, cex = 0.5),
alternating = 3))
Now if I am understanding lattice correctly setting symb$cex sets the size
multiplier for symbols within each group but does not support the
differential sizing of symbols for each record independently within each
group. Hence I have tried to use a 'global' cex (after the groups
statement), however, this has no effect on the displayed symbol size. Do I
need to change the pch or another parameter to draw sized filled circles as
is the default symbol for dotplot?
Thanks
Dave
----------------------------------------------------------------------------------------------
David M. Kidd
Research Assistant
School of Biology
Room 210, Sir Harold Mitchell Building
University of St. Andrews
St. Andrews, Fife
KY16 9TH
UK
http://www.st-and.ac.uk/~bugs/dave/dave.htm
Tel: +44 (0)1334 463348
Fax: +44 (0)1334 463600
Lattice dotplot with symbols sized and colored
2 messages · David Kidd, Deepayan Sarkar
On Tuesday 03 May 2005 06:39, David Kidd wrote:
Sundar suggested setting up a theme which I have done...
my.theme <- function() {
theme <- col.whitebg()
symb <- theme$superpose.symbol
symb$col=
c("red","blue","green","yellow","orange","black","purple") #symb$pch
is c(1,3,6,0,5,16,17) by default for col.whitebg
theme$superpose.symbol <- symb
theme
}
trellis.par.set(theme = my.theme())
# from ?dotplot
dotplot(sporder ~ cvarorder | direct, data=sp.nc.bdrs.data,
groups = sp.nc.bdrs.data$mysign,
cex=abs(sp.nc.bdrs.data$mwZ * 0.05),
xlab="climate variables",
ylab="species",
scales = list(y = list(labels = as.character(spname),at = 1:12, cex =
0.5), x = list(labels = as.character(my.ylabel), at = 1:66, rot=90,
cex = 0.5), alternating = 3))
Now if I am understanding lattice correctly setting symb$cex sets the
size multiplier for symbols within each group but does not support
the differential sizing of symbols for each record independently
within each group. Hence I have tried to use a 'global' cex (after
the groups statement), however, this has no effect on the displayed
symbol size. Do I need to change the pch or another parameter to draw
sized filled circles as is the default symbol for dotplot?
Yes, canned features of lattice are not enough for this. Here's
something that should work:
with(sp.nc.bdrs.data,
dotplot(sporder ~ cvarorder | direct,
col.var = factor(mysign),
cex.var = abs(mwZ),
col = c('green', 'red'),
panel = function(x, y, cex, col, cex.var, col.var,
subscripts, ...) {
panel.dotplot(x, y,
col = col[col.var[subscripts]],
cex = cex.var[subscripts] * 0.05, ...)
}))
Here's a version with the barley data (not a very good example, though):
with(barley,
dotplot(site ~ yield,
col.var = factor(year),
cex.var = yield,
col = c('green', 'red'),
panel = function(x, y, cex, col, cex.var, col.var,
subscripts, ...) {
panel.dotplot(x, y,
col = col[col.var[subscripts]],
cex = cex.var[subscripts] * 0.03, ...)
}))
Deepayan