[R] different plot symbols in key using xyplot

Peter Ehlers ehlers at ucalgary.ca
Sun Oct 25 20:24:52 CET 2009


Stephen Kennedy wrote:
> I'm using xyplot in a very simple way---a scatter plot of several data  
> sets.  I'm having a problem getting auto.key to display different  
> point characters.
> 
> The following produces a plot that employes different colors, all with  
> pch(1), for the different groups, with a matching key.
> 
> xyplot(Force~Time, rawData, groups=Sample, panel = panel.superpose,  
> auto.key=TRUE)
> 
> 
> The following produces a plot that employs different symbols (and  
> colors) for the groups, but the key still uses pch(1) for all groups.   
> I assume I need to set some more general option, but haven't found it  
> yet.
> 
> xyplot(Force~Time, rawData, groups=Sample, pch=0:18, panel =  
> panel.superpose, auto.key=list(space="right", pch=0:18))
> 
> 
> What I would really like is a plot with different symbols, all with  
> black color.  The following works for the plot, but again has no  
> effect on the key.
> 
> xyplot(Force~Time, rawData, groups=Sample, pch=0:18, col="black",  
> panel = panel.superpose, auto.key=list(space="right", pch=0:18))

Try this:

xyplot(Sepal.Width ~ Petal.Width, data = iris, groups = Species,
   par.settings = list(superpose.symbol = list(col = 1, pch = 0:2)),
   auto.key = TRUE)

  -Peter Ehlers

> 
> 
> Thanks,
> 
> Steve Kennedy
> 
> 
> Stephen J. Kennedy, Ph.D.
> Consulting
> Contract Research & Development
> PLEASE NOTE: NEW EMAIL ADDRESS
> StephenJKennedy at myfairpoint.net
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list