John Sorkin
2011-Jan-12 19:19 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? 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}}
Sarah Goslee
2011-Jan-12 19:23 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
You don't give an example, but in general you can use a vector for cex with the values proportional to the third variable. Same goes for color: col can be a vector, not just a single value. This has been discussed before on-list, and fairly recently. Sarah On Wed, Jan 12, 2011 at 2:19 PM, John Sorkin <jsorkin at grecc.umaryland.edu> wrote:> I would like to plot 3-dimensional data on a two-dimensional scatter-plot. > Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? > Thanks, > John >-- Sarah Goslee http://www.functionaldiversity.org
Greg Snow
2011-Jan-12 20:26 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
Look at the symbols function for some options of doing what you suggest (you can also do a search for "bubble plot" for a couple of other implementations). If you want to go a bit further than what symbols does for you then look at the my.symbols function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of John Sorkin > Sent: Wednesday, January 12, 2011 12:19 PM > To: r-help at r-project.org > Subject: [R] 2d plot with modification of plotting symbol to indicate > third dimension. > > I would like to plot 3-dimensional data on a two-dimensional scatter- > plot. > Is there a way I can automatically modify the plot symbol (e.g. > changing size or color) to indicate the value of a third variable? E.g. > How can I plot weight vs. age and indicate the value of muscle mass for > each value weight-age pair by making the plot point proportional to the > subject's muscle mass? > 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.
Bert Gunter
2011-Jan-12 21:08 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
Google on "R Graph Gallery" to find examples with code. You can also almost certainly RSiteSearch() on appropriate keys to find a pre-existing function (which someone may provideyou on the list). Also: ?symbols -- Bert On Wed, Jan 12, 2011 at 11:19 AM, John Sorkin <jsorkin at grecc.umaryland.edu> wrote:> I would like to plot 3-dimensional data on a two-dimensional scatter-plot. > Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? > 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. >-- Bert Gunter Genentech Nonclinical Biostatistics 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml
John Sorkin
2011-Jan-13 02:33 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
I would like to plot 3-dimensional data on a two-dimensional scatter-plot. Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass? 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}}
Jim Lemon
2011-Jan-13 06:06 UTC
[R] 2d plot with modification of plotting symbol to indicate third dimension.
On 01/13/2011 06:19 AM, John Sorkin wrote:> I would like to plot 3-dimensional data on a two-dimensional scatter-plot. > Is there a way I can automatically modify the plot symbol (e.g. changing size or color) to indicate the value of a third variable? E.g. How can I plot weight vs. age and indicate the value of muscle mass for each value weight-age pair by making the plot point proportional to the subject's muscle mass?Hi John, I think Greg's suggestions should do what you want, but if not, have a look at the example for the color.scale function (plotrix). Jim