[R] x y plot with z coordinate scaling to a color value
Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Thanks for your help! Jannis __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
On 05/19/2010 08:24 PM, Jannis wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Hi Jannis, Have a look at the example for color.scale in the plotrix package, and you already know about color.legend. Jim __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
Hi Jannis, You can have a look at image(), or alternatively look at spplot. The latter assumes that you have your data structured according to the spatial R classes that the sp-package provides: library(sp) data(meuse.grid) head(meuse.grid) summary(meuse.grid) # transform to sp-object gridded(meuse.grid) = ~x+y summary(meuse.grid) spplot(meuse.grid, dist) cheers, Paul On 05/19/2010 12:24 PM, Jannis wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Thanks for your help! Jannis __ R-help@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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
Hi, See also ?lattice::xyplot and ?ggplot2::geom_point , either one can do it automatically. HTH, baptiste On 19 May 2010 12:24, Jannis bt_jan...@yahoo.de wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Thanks for your help! Jannis __ R-help@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. __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
And made slightly easier with panel.levelplot.points from latticeExtra: http://latticeextra.r-forge.r-project.org/#panel.levelplot.points On 19 May 2010 22:24, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, See also ?lattice::xyplot and ?ggplot2::geom_point , either one can do it automatically. HTH, baptiste On 19 May 2010 12:24, Jannis bt_jan...@yahoo.de wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Thanks for your help! Jannis __ R-help@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. __ R-help@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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
the package ggplot2 makes it really really easy! qplot(x,y,data=yourdataset, colour= color) __ R-help@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.
Re: [R] x y plot with z coordinate scaling to a color value
Sorry, that should be qplot(x,y,data=yourdataset, colour= z) On Thu, May 20, 2010 at 3:07 PM, Daisy Englert Duursma daisy.duur...@gmail.com wrote: the package ggplot2 makes it really really easy! qplot(x,y,data=yourdataset, colour= color) -- Daisy Englert Duursma Room E8C156 Dept. Biological Sciences Macquarie University NSW 2109 Australia Tel +61 2 9850 9256 10A Carrington Rd Hornsby, NSW 2077 Mobile: 0421858456 __ R-help@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.