Re: [R] Plotting symbols and colors based upon data values

From: David Winsemius <>
Date: Sat, 12 Mar 2011 22:38:46 -0500

On Mar 12, 2011, at 7:57 PM, Mark Linderman wrote:

> I am new to R and am sure this is simple, but I been unable to find a
> solution.
> I have 5 columns of data labeled "X", "Y", "A","B","C". I can easily
> xyplot(Y ~ X | A) but I want the colors of the symbols to be based
> upon the
> values of B and the shape of the symbols to be determined by C.
> There are
> approximately four distinct values of B and C (say
> "b1","b2","b3","b4" and
> "c1","c2","c3","c4", respectively)
No data to check it against (despite the request for such that accompanies every posting) but see if this give the desired result:

xyplot(Y ~ X | A, data=dfrm2, pch=dfrm2$C , col=dfrm2$B)

> Either a solution or a pointer to a specific reference/example is
> greatly
> appreciated.

There are many in the contributed documentation as well as in Sarkar's book website and in the graphics galleries. As you suggested, it's pretty basic stuff since you are benefiting from Sarkar's effort to carry over some of the argument names from basic graphics. The one "trick" is to not rely on the argument being assumed to come from the environment of the `data` argument.


David Winsemius, MD
West Hartford, CT

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 13 Mar 2011 - 03:43:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Mar 2011 - 04:20:21 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive