An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090327/d975ef35/attachment-0002.pl>
color vectors other than gray()
10 messages · Romain Francois, Baptiste Auguie, Tsjerk Wassenaar +3 more
See ?colorRampPalette and ?colorRamp
colorRampPalette( c("blue", "white", "red") )(100)
colorRamp( c("blue", "white", "red") )( 0:10 / 10 )
Romain
Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a shapefile)
will be painted with a color share scale, where the most easy way is to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os limites
min e max do N de indiv?duos observados
color.legend(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________ Paulo E. Cardoso
Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr
?colorRamp Hope this helps, baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________ Paulo E. Cardoso [[alternative HTML version deleted]] <ATT00001.txt>
_____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
Hi, Have a look at: ?rainbow ?rgb ?heatmap In my opinion this would've likely popped up with just a little effort of searching. In fact, the help of grey() (?grey) already gives pointers to the other color functions. Please show that you at least have tried to find answers before posting questions on a user list. Tsjerk
On Fri, Mar 27, 2009 at 2:16 PM, Paulo E. Cardoso <pecardoso at netcabo.pt> wrote:
I'm trying to create a graph where different cells of a grid (a shapefile)
will be painted with a color share scale, where the most easy way is to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors with
other methods but gray()?
I'm doing this until now
?quad_N_sp <-
merge(sp_dist[sp_dist$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
?quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
?quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
?paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
?win.graph(4,5)
?plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e gradiente
de abund?ncia
?fg=paleta,
?cex.lab=0.7,
?cex.axis=0.7,
?cex.main=0.7,
?xlab="Coord X",
?ylab="Coord Y",
?main=paste("Esp?cie: ",splist[i]),
?xlim=c(210000,240000)
?)
?col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os limites
min e max do N de indiv?duos observados
color.legend(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
?text(245300,130500,"N? Indiv?duos",cex=0.6)
?plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________ Paulo E. Cardoso ? ? ? ?[[alternative HTML version deleted]] ______________________________________________ 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.
Tsjerk A. Wassenaar, Ph.D. Junior UD (post-doc) Biomolecular NMR, Bijvoet Center Utrecht University Padualaan 8 3584 CH Utrecht The Netherlands P: +31-30-2539931 F: +31-30-2537623
On Fri, 27 Mar 2009, Tsjerk Wassenaar wrote:
Hi, Have a look at: ?rainbow ?rgb ?heatmap
Furthermore, the packages colorspace, ggplot, plotrix, and RColorBrewer have useful tools for this. For the ides behind the palettes in colorspace, see Achim Zeileis, Kurt Hornik, and Paul Murrell (2009). Escaping RGBland: Selecting Colors for Statistical Graphics. Computational Statistics & Data Analysis, Forthcoming. doi:10.1016/j.csda.2008.11.033 Preprint: http://statmath.wu-wien.ac.at/~zeileis/papers/Zeileis+Hornik+Murrell-2008.pdf hth, Z
In my opinion this would've likely popped up with just a little effort of searching. In fact, the help of grey() (?grey) already gives pointers to the other color functions. Please show that you at least have tried to find answers before posting questions on a user list. Tsjerk On Fri, Mar 27, 2009 at 2:16 PM, Paulo E. Cardoso <pecardoso at netcabo.pt> wrote:
I'm trying to create a graph where different cells of a grid (a shapefile)
will be painted with a color share scale, where the most easy way is to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors with
other methods but gray()?
I'm doing this until now
?quad_N_sp <-
merge(sp_dist[sp_dist$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
?quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
?quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
?paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
?win.graph(4,5)
?plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e gradiente
de abund?ncia
?fg=paleta,
?cex.lab=0.7,
?cex.axis=0.7,
?cex.main=0.7,
?xlab="Coord X",
?ylab="Coord Y",
?main=paste("Esp?cie: ",splist[i]),
?xlim=c(210000,240000)
?)
?col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os limites
min e max do N de indiv?duos observados
color.legend(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
?text(245300,130500,"N? Indiv?duos",cex=0.6)
?plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________ Paulo E. Cardoso ? ? ? ?[[alternative HTML version deleted]] ______________________________________________ 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.
-- Tsjerk A. Wassenaar, Ph.D. Junior UD (post-doc) Biomolecular NMR, Bijvoet Center Utrecht University Padualaan 8 3584 CH Utrecht The Netherlands P: +31-30-2539931 F: +31-30-2537623
______________________________________________ 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.
I'm certainly missing something. In fact the ramp I need must be scaled according to a vector of values (in this case species abundance in each grid cell), as in the example vector below:
length(quad_N_sp$x) # where x is the abundance value
[1] 433 quad_N_sp$x [1] 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 [101] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [201] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [301] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [401] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level). I don't know how to proceed. ____________ Paulo E. Cardoso -----Mensagem original----- De: baptiste auguie [mailto:ba208 at exeter.ac.uk] Enviada: sexta-feira, 27 de Mar?o de 2009 13:30 Para: Paulo E. Cardoso Cc: r-help at stat.math.ethz.ch; r-help at r-project.org Assunto: Re: [R] color vectors other than gray() ?colorRamp Hope this helps, baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________ Paulo E. Cardoso [[alternative HTML version deleted]] <ATT00001.txt>
_____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag ______________________________ No virus found in this incoming message. Checked by AVG - www.avg.com 03/27/09 07:13:00
Can you provide a minimal example that we can run directly after copy and paste (using a standard data set or dummy data)? It's always helpful to try and nail down the core of your question (often you'll find the answer while formulating your question in minimal terms). baptiste
On 27 Mar 2009, at 14:36, Paulo E. Cardoso wrote:
I'm certainly missing something. In fact the ramp I need must be scaled according to a vector of values (in this case species abundance in each grid cell), as in the example vector below:
length(quad_N_sp$x) # where x is the abundance value
[1] 433 quad_N_sp$x [1] 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 [101] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [201] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [301] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [401] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level). I don't know how to proceed.
____________
Paulo E. Cardoso
-----Mensagem original-----
De: baptiste auguie [mailto:ba208 at exeter.ac.uk]
Enviada: sexta-feira, 27 de Mar?o de 2009 13:30
Para: Paulo E. Cardoso
Cc: r-help at stat.math.ethz.ch; r-help at r-project.org
Assunto: Re: [R] color vectors other than gray()
?colorRamp
Hope this helps,
baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________
Paulo E. Cardoso
[[alternative HTML version deleted]]
<ATT00001.txt>
_____________________________
Baptiste Augui?
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.11.30/2026 - Release Date:
03/27/09
07:13:00
_____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
Hi r-help-bounces at r-project.org napsal dne 27.03.2009 15:36:23:
I'm certainly missing something. In fact the ramp I need must be scaled according to a vector of values
(in
this case species abundance in each grid cell), as in the example vector below:
length(quad_N_sp$x) # where x is the abundance value
[1] 433 quad_N_sp$x [1] 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0
0 3
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 [101] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [201] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [301] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [401] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level).
If I understand correctly pal<-grey(0:max(quad_N_sp$x)/max(quad_N_sp$x)) shall give you vector of equally spaced grey values pal[quad_N_sp$x+1] shall give you shadings for each quad_N_sp$x value Regards Petr
I don't know how to proceed.
____________
Paulo E. Cardoso
-----Mensagem original-----
De: baptiste auguie [mailto:ba208 at exeter.ac.uk]
Enviada: sexta-feira, 27 de Mar?o de 2009 13:30
Para: Paulo E. Cardoso
Cc: r-help at stat.math.ethz.ch; r-help at r-project.org
Assunto: Re: [R] color vectors other than gray()
?colorRamp
Hope this helps,
baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________
Paulo E. Cardoso
[[alternative HTML version deleted]]
<ATT00001.txt>
_____________________________
Baptiste Augui?
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________
No virus found in this incoming message.
Checked by AVG - www.avg.com
03/27/09
07:13:00
______________________________________________
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.
OK
I got it working partially.
The plot results in a ramp varying from white -> red -> black, doing this:
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e gradiente de
abund?ncia
fg=color.scale(((1-(quad_N_sp$x)/max(quad_N_sp$x))),c(0,1,1),c(0,1),c(0,1)),
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
Where the ramp results from the red, green, blue ranges used in:
color.scale(((1-(quad_N_sp$x)/max(quad_N_sp$x))),c(0,1,1),c(0,1),c(0,1))
I don't know how to control the ramp. In this particular case it results
reasonably well but I ave no idea how to control the RGB channels to produce
a ramp-of-interest.
Attached workspace contains a data sample to create the plot.
Use the code below:
library(maptools)
library(plotrix)
pallete <- color.scale(vec.ab.01,c(0,1,1),c(0,1),c(0,1))
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e gradiente de
abund?ncia
fg=pallete,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ","Carduelis carduelis"),
xlim=c(210000,240000)
)
col_lab <- c(max(vec.ab),min(vec.ab)) #! Vector com os limites min e max do
N de indiv?duos observados
color.legend(248000,120000,250000,128000,col_lab,sort(unique(pallete)),gradi
ent="y",cex=0.7)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
____________
Paulo E. Cardoso
-----Mensagem original-----
De: baptiste auguie [mailto:ba208 at exeter.ac.uk]
Enviada: sexta-feira, 27 de Mar?o de 2009 14:50
Para: Paulo E. Cardoso
Cc: r-help at stat.math.ethz.ch; r-help at r-project.org
Assunto: Re: [R] color vectors other than gray()
Can you provide a minimal example that we can run directly after copy
and paste (using a standard data set or dummy data)?
It's always helpful to try and nail down the core of your question
(often you'll find the answer while formulating your question in
minimal terms).
baptiste
On 27 Mar 2009, at 14:36, Paulo E. Cardoso wrote:
I'm certainly missing something. In fact the ramp I need must be scaled according to a vector of values (in this case species abundance in each grid cell), as in the example vector below:
length(quad_N_sp$x) # where x is the abundance value
[1] 433 quad_N_sp$x [1] 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 [101] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [201] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [301] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [401] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level). I don't know how to proceed.
____________
Paulo E. Cardoso
-----Mensagem original-----
De: baptiste auguie [mailto:ba208 at exeter.ac.uk]
Enviada: sexta-feira, 27 de Mar?o de 2009 13:30
Para: Paulo E. Cardoso
Cc: r-help at stat.math.ethz.ch; r-help at r-project.org
Assunto: Re: [R] color vectors other than gray()
?colorRamp
Hope this helps,
baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________
Paulo E. Cardoso
[[alternative HTML version deleted]]
<ATT00001.txt>
_____________________________
Baptiste Augui?
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.11.30/2026 - Release Date:
03/27/09
07:13:00
_____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag ______________________________ No virus found in this incoming message. Checked by AVG - www.avg.com 03/27/09 07:13:00
Petr, I'd like to be able to change the ramp to other than grey shades. Please see my previous message with some data. ____________ Paulo E. Cardoso -----Mensagem original----- De: Petr PIKAL [mailto:petr.pikal at precheza.cz] Enviada: sexta-feira, 27 de Mar?o de 2009 15:12 Para: Paulo E. Cardoso Cc: r-help at stat.math.ethz.ch Assunto: Re: [R] color vectors other than gray() Hi r-help-bounces at r-project.org napsal dne 27.03.2009 15:36:23:
I'm certainly missing something. In fact the ramp I need must be scaled according to a vector of values
(in
this case species abundance in each grid cell), as in the example vector below:
length(quad_N_sp$x) # where x is the abundance value
[1] 433 quad_N_sp$x [1] 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0
0 3
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 [101] 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [201] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [301] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 0 0
0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [401] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level).
If I understand correctly pal<-grey(0:max(quad_N_sp$x)/max(quad_N_sp$x)) shall give you vector of equally spaced grey values pal[quad_N_sp$x+1] shall give you shadings for each quad_N_sp$x value Regards Petr
I don't know how to proceed.
____________
Paulo E. Cardoso
-----Mensagem original-----
De: baptiste auguie [mailto:ba208 at exeter.ac.uk]
Enviada: sexta-feira, 27 de Mar?o de 2009 13:30
Para: Paulo E. Cardoso
Cc: r-help at stat.math.ethz.ch; r-help at r-project.org
Assunto: Re: [R] color vectors other than gray()
?colorRamp
Hope this helps,
baptiste
On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote:
I'm trying to create a graph where different cells of a grid (a
shapefile)
will be painted with a color share scale, where the most easy way is
to use
gray().
Can I somehow get a vector (gradient) of colors, a vector of colors
with
other methods but gray()?
I'm doing this until now
quad_N_sp <-
merge(sp_dist[sp_dist
$sp==splist[i],],grelha_ID,by.x="quad",by.y="quadricula
",all.y=T,)
quad_N_sp$x[is.na(quad_N_sp$x)] <- 0
quad_N_sp <- quad_N_sp[order(quad_N_sp$id),]
paleta <- gray(1-(quad_N_sp$x)/max(quad_N_sp$x)) #! Tons de cinzento
win.graph(4,5)
plot(grelha,ol="grey80", #! Gr?fico com grelha de amostragem e
gradiente
de abund?ncia
fg=paleta,
cex.lab=0.7,
cex.axis=0.7,
cex.main=0.7,
xlab="Coord X",
ylab="Coord Y",
main=paste("Esp?cie: ",splist[i]),
xlim=c(210000,240000)
)
col_lab <- c(max(quad_N_sp$x),min(quad_N_sp$x)) #! Vector com os
limites
min e max do N de indiv?duos observados
color
.legend
(248000,120000,250000,128000,col_lab,sort(unique(paleta)),gradie
nt="y",cex=0.6)#! Legenda
text(245300,130500,"N? Indiv?duos",cex=0.6)
plot(blocos,ol="grey40",fg=NA,add=T)
I'd like to replace the grey shade by other colors.
Thanks in advance
____________
Paulo E. Cardoso
[[alternative HTML version deleted]]
<ATT00001.txt>
_____________________________
Baptiste Augui?
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________
No virus found in this incoming message.
Checked by AVG - www.avg.com
03/27/09
07:13:00
______________________________________________
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.
No virus found in this incoming message. Checked by AVG - www.avg.com 03/27/09 07:13:00