David Kidd wrote on 5/3/2005 3:08 AM:

Apologies if this is a naive beginners question.

I am trying to create a dotplot with the lattice dotplot function in which my dots are colored differently depending on if positive or negative and sized by sp.nc.bdrs.data$mwZ

I have tried...

dotplot(sporder ~ cvarorder | direct, data=sp.nc.bdrs.data,
cex=abs(sp.nc.bdrs.data$mwZ * 0.05),
xlab="climate variables",
ylab="species",col= sp.nc.bdrs.data$mysign,
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))


This sizes my symbols correctly but colors all four conditional plots (direct = 'e', 'n', 's' & 'w') using the colors defined for the first direct condition (i.e. 'e').

I have also tried using 'groups' to set the colors, however, whenever I do this I cannot get cex to then size the symbols - I get open circles that do not scale. This problem also happens when I try setting up a panel function.

Many Thanks





Hi David,

I think you're on the right track using groups. However, you just have to set the trellis arguments correctly. For example,

library(lattice)
my.theme <- function() {
  theme <- col.whitebg()
  symb <- theme$superpose.symbol
  symb$cex <- seq(0.5, 1.5, length = length(symb$cex))
  # 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(variety ~ yield | year, data = barley, groups = site)

It's not necessary to create a theme. You can accomplish the same just using trellis.par.get and trellis.par.set. The above is just my personal preference.

HTH,

--sundar

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to