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

Peter Alspach Peter.Alspach at plantandfood.co.nz
Mon Apr 11 04:59:46 CEST 2011


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
> th...{{dropped:6}}
> 
> ______________________________________________
> 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.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list