mister_bluesman
2007-May-07 14:00 UTC
[R] Representing a statistic as a colour on a 2d plot
Hello. I have a 2d plot which looks like this: http://www.nabble.com/file/8242/1.JPG This plot is derived from a file that holds statistics about each point on the plot and looks like this: a b c d e a 0 0.498 0.473 0.524 0.528 b 0.498 0 0 0 0 c 0.473 0 0 0 0 d 0.524 0 0 0 0 e 0.528 0 0 0 0 However, I have another file called 2.txt, with the following contents: a b c d e 0.5 0.7 0.32 0.34 0.01 What I would like to know is how do I convert these values in 2.txt to colours or colour intensities so that the x's in the diagram above can be colour coded as such. Many thanks. -- View this message in context: http://www.nabble.com/Representing-a-statistic-as-a-colour-on-a-2d-plot-tf3703885.html#a10357828 Sent from the R help mailing list archive at Nabble.com.
J.delasHeras at ed.ac.uk
2007-May-07 14:30 UTC
[R] Representing a statistic as a colour on a 2d plot
check ?rainbow to generate the colours (which also shows you other related functions like 'heat.colors' that you may also find useful. To plot the coloured points, check ?points. hope this helps a bit Jose Quoting mister_bluesman <mister_bluesman at hotmail.com>:> > Hello. > > I have a 2d plot which looks like this: > > http://www.nabble.com/file/8242/1.JPG > > This plot is derived from a file that holds statistics about each point on > the plot and looks like this: > > a b c d e > a 0 0.498 0.473 0.524 0.528 > b 0.498 0 0 0 0 > c 0.473 0 0 0 0 > d 0.524 0 0 0 0 > e 0.528 0 0 0 0 > > However, I have another file called 2.txt, with the following contents: > > a b c d e > 0.5 0.7 0.32 0.34 0.01 > > What I would like to know is how do I convert these values in 2.txt to > colours or colour intensities so that the x's in the diagram above can be > colour coded as such. > > Many thanks. > -- > View this message in context: > http://www.nabble.com/Representing-a-statistic-as-a-colour-on-a-2d-plot-tf3703885.html#a10357828 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > >-- Dr. Jose I. de las Heras Email: J.delasHeras at ed.ac.uk The Wellcome Trust Centre for Cell Biology Phone: +44 (0)131 6513374 Institute for Cell & Molecular Biology Fax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK
mister_bluesman wrote:> Hello. > > I have a 2d plot which looks like this: > > http://www.nabble.com/file/8242/1.JPG > > This plot is derived from a file that holds statistics about each point on > the plot and looks like this: > > a b c d e > a 0 0.498 0.473 0.524 0.528 > b 0.498 0 0 0 0 > c 0.473 0 0 0 0 > d 0.524 0 0 0 0 > e 0.528 0 0 0 0 > > However, I have another file called 2.txt, with the following contents: > > a b c d e > 0.5 0.7 0.32 0.34 0.01 > > What I would like to know is how do I convert these values in 2.txt to > colours or colour intensities so that the x's in the diagram above can be > colour coded as such.Yo bluesman, check color.scale in the plotrix package, cat it'll color your points to the values they're at Jim
mister_bluesman
2007-May-08 20:02 UTC
[R] Representing a statistic as a colour on a 2d plot
Thanks people! Sorry to sound thick but after I download the plotrix package, how do i install it? Thank you! -- View this message in context: http://www.nabble.com/Representing-a-statistic-as-a-colour-on-a-2d-plot-tf3703885.html#a10383035 Sent from the R help mailing list archive at Nabble.com.
How did you download it? In Windows if you used the Packages > Install packages route it is installed. Just type library(plotrix) to load it. No idea for Linux or Mac. --- mister_bluesman <mister_bluesman at hotmail.com> wrote:> > Thanks people! Sorry to sound thick but after I > download the poltrix package, > how do i install it? > > Thank you! > -- > View this message in context: >http://www.nabble.com/Representing-a-statistic-as-a-colour-on-a-2d-plot-tf3703885.html#a10383035> Sent from the R help mailing list archive at > Nabble.com. > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
mister_bluesman wrote:> Thanks people! Sorry to sound thick but after I download the poltrix package, > how do i install it? > > Thank you!which platform are you on? On Windows I would suggest you use the Menu of the GUI "Install packages from local zip files" in the main category 'packages' On Linux I usually do on the command line: R CMD INSTALL plotrix_2.2.tar.gz I hope this helps? Best, Roland P.S. I am pretty sure it is described somewhere in the included manuals.
mister_bluesman
2007-May-10 11:46 UTC
[R] Representing a statistic as a colour on a 2d plot
Hi Jim. Thanks for all your help. But would this ensure that, say, the color for the value 0.1 would ALWAYS be the SAME and ALWAYS be DIFFERENT from that of other values, regardless of the size of the vector? CHEERS Jim Lemon-2 wrote:> > mister_bluesman wrote: >> Ive been getting the color.scale function to work. However, I really need >> to >> know is that if i have values: 0.1 0.2, 0.3, 0.4, 0.5, for example, how I >> can plot these using colours that would be different if the contents of >> the >> file were 0.6, 0.7, 0.8, 0.9 and 1.0. Using color.scale scales them so >> that >> they differ, but only relative to each other, rather than taking the >> actual >> value and converting them to some unique colour/colour intensity. >> >> Many thanks >> > There are a couple of ways to go about this. If you know that there are > say ten possible values, you can use the color.gradient function to > assign ten colors across a particular range. Then you would have to map > the colors to the numbers (I would do something like creating a two > element list of the sorted unique numbers and the colors. Then assign > the color vector for the plot from this list.) Note that both > color.scale and color.gradient are aimed at producing colors that > visually represent some range like cold(blue) to hot(red). If you just > want to get 20 easily discriminated colors and assign them to values, > you might be better off with ColorBrewer. > > Jim > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > >-- View this message in context: http://www.nabble.com/Representing-a-statistic-as-a-colour-on-a-2d-plot-tf3703885.html#a10411818 Sent from the R help mailing list archive at Nabble.com.