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

From: John Sorkin <jsorkin_at_grecc.umaryland.edu>
Date: Sun, 10 Apr 2011 23:32:45 -0400

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}}



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. Received on Mon 11 Apr 2011 - 03:41:15 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 11 Apr 2011 - 06:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive