[R] Specifying the color of points and the plot symbol to be used on a graph

John Sorkin jsorkin at grecc.umaryland.edu
Mon Apr 11 05:32:45 CEST 2011


Thank you! An elegant solution to my problem!
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> Peter Alspach <Peter.Alspach at plantandfood.co.nz> 4/10/2011 10:59 PM >>>
Tena koe John

If I understand you correctly I think it is easier than that:

plot(x, y, col=yourColourVariate, pch=yourPchVariate)

where yourColourVariate and yourPchVariate are numeric variates of the same lengths as x and y (recycling occurs).  Actually the former can be a character variate of legal names.

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of John Sorkin
> Sent: Monday, 11 April 2011 2:29 p.m.
> To: r-help at r-project.org 
> Subject: [R] Specifying the color of points and the plot symbol to be
> used on a graph
> 
> R 2.12.2
> Windows 7
> 
> I would like to know how to specify the color used in plotting points
> on a scatter plot, generated using plot(x,y) and how I can specify the
> particular symbol used. I would like, for example, to plot some points
> as blue circles and other points a red squares. If someone will tell me
> how to specify the symbol and color used when plotting points, I can
> overlay graphs [par(new=TRUE] to get the two colors I desire.
> 
> Thanks,
> John
> 
> 
> 
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> 
> Confidentiality Statement:
> This email message, including any attachments, is for\...{{dropped:31}}



More information about the R-help mailing list