[R-sig-eco] scatter plot color gradient

Cliff Beall cliffbeall at gmail.com
Tue Nov 8 22:21:46 CET 2011


There's a function called rainbow that makes a vector of colors. Assuming your dataframe is called "rodrigo":

> plot(rodrigo$Lat, rodrigo$Long, pch=21, bg=rainbow(3)[rodrigo$Day+1])
> legend("topleft", pch=21, pt.bg=rainbow(3), legend=c("Day 1", "Day 2", "Day 3"))

Just use rainbow(30) if you have 30 days.


On Nov 8, 2011, at 3:03 PM, Rodrigo Plei wrote:

> Dear all,
> 
> I have a dataset (table) with daily geographycal coordinates
> (latitude-longitude) for a fish larvae population that looks like as this:
> 
> Day    Lat    Long
> 0        23.3    47.2
> 0        23.35  47.0
> 0        23.4    47.0
> 0        23.4    47.3
> 1        24.2    47.5
> 1        24.1    47.23
> 1        24.4    47.8
> 1        24.36   47.85
> 2        24.5     47.8
> 2        25.2     48.1
> 2        25.3     48.2
> .
> .
> 
> In other words: each row corresponds to a single larva position in a given
> date.
> 
> I would like to plot the trajectory of the whole larvae population
> as a simple dispersion  for the entire period studied, but the idea is
> that each point has a color according to age (days) in order to
> form agradient with the colors of the rainbow . Also, I want a caption bar
> (legend)  for the gradient (for example, day 0 = yellow and day 30 = red).
> 
> Anybody around can help me out with that, or at least indicate a packege
> that may be useful to me?
> 
> I acknowlede your attention in advance.
> 
> Regards,
> 
> Rodrigo
> -- 
> =8-->=8-->=8-->=8-->=8-->=8-->=8-->=8-->=8-->=8-->=8-->=8-->
> 
> Rodrigo Silvestre Martins, PhD
> Bolsista FAPESP Pós-Doutorado
> 
> Laboratório de Ecossistemas Pesqueiros (LabPesq)
> Universidade de São Paulo, Instituto Oceanográfico
> Praça do Oceanográfico, 191. Cidade Universitaria (sala 107-A/B)
> Butantã - São Paulo/SP, Brasil
> 05508-900
> Tel: +55 11 3091 6549
> Email: rodrigo.plei at gmail.com ; ocersm at lycos.com; rsmartins at usp.br
> 
> CV Lattes: http://lattes.cnpq.br/5350064124902777
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Cliff Beall
Research Assistant Professor
Division of Oral Biology
College of Dentistry
The Ohio State University
beall.3 at osu.edu



More information about the R-sig-ecology mailing list