Skip to content
Prev 69019 / 398502 Next

Lattice dotplot with symbols sized and colored

On Tuesday 03 May 2005 06:39, David Kidd wrote:
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