r - Specify color of symbols for group levels in panels of a conditioned scatterplot matrix made with splom? -


how specify color of group levels in panels of conditioned scatterplot matrix generated using splom? can in key, find no arguments symbols in panel.pairs. not key not match panels, colors assigned group levels should male=blue, female=pink.

dput(head(dfso,20)) structure(list(mhi = c(67460l, 89033l, 61836l, 49853l, 88772l,                         105107l, 94744l, 56061l, 49435l, 68027l, 152673l, 56408l,                         74493l, 53048l, 62485l, 96712l, 90211l, 81249l,                         111576l, 102231l),                 gender = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l,                                      1l, 1l, 1l, 2l, 2l, 1l, 1l, 1l, 1l),                                    .label = c("female", "male"),                                    class = "factor"),                happy = c(4, 4, 1, 4, 3, 3, 3, 3,                          2, 4, 3, 4, 3, 4, 3, 1, 4, 3, 3, 2)),           .names = c("mhi", "gender", "happy"), row.names = c(na, 20l),            class = "data.frame") library(lattice) super.sym <- trellis.par.get("superpose.symbol") #where can customize key splom(dfso, groups=dfso$gender, subset=true, panel=panel.superpose,       key=list(title="by gender", columns=2,                points=list(pch=super.sym$pch[1],col=super.sym$col[1:2]),                text=list(c("male","female")))) 

when changing graphical parameters in lattice graphics, favorite approach pass parameters par.settings argument. changes graphics settings current plot doesn't alter global settings found trellis.par.get().

(i change key argument auto.key.)

you on right track superpose.symbol settings! order of grouping variable levels (male , female) determines color gets assigned level. since levels ordered alphabetically, female first color.

first, create object desired graphical parameters:

mypars <- list(superpose.symbol = list(pch = super.sym$pch[1], col = c("pink", "blue"))) 

then pass splom via par.settings argument (notice altered key well).

splom(dfso, groups = dfso$gender, subset = true, panel = panel.superpose,     auto.key = list(title="by gender", columns=2),     par.settings = mypars) 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -