[R] cuts and breaks

Winfried Theis theis at statistik.uni-dortmund.de
Thu Sep 27 18:07:40 CEST 2001


Hi!
On 27-Sep-01 José Ernesto Jardim wrote:
> Hi
> 
> I'm using the "image" function to produce a plot and I want to define 
> the breaks using "cut" and the colors using "heat.colors".
> 
>  > 
>
image(interp(mat2[,2],mat2[,1],mat2[,3]),breaks=cut(mat2[,3],30),col=
heat.colo
> rs(29))

> Error in image.default(interp(mat2[, 2], mat2[, 1], mat2[, 3]), breaks = 
> cut(mat2[,  :
>         must have one more break than colour
> 
> 
> The error message is not clear to me because I'm using 30 to cut and 29 
> to heat.colors.
> 
> What am I doing wrong ?
I think you use the wrong function for your purpose: "cut" converts a numeric
vector into a factor with levels correponding to intervalls -- but here you
need to define the breakpoints for the intervalls for which each colour is
used. Something along the lines:

brks<-seq(from=range(mat2[,3],finite=TRUE)[1],to=range(mat2[,3],finite=TRUE)[2],
30)
image(interp(mat2[,2],mat2[,1],mat2[,3]),breaks=brks,col=heat.colors(29))

should do the trick.

Maybe you should check the functions you want to use first on their real
behaviour...

Cheers, Winfried


----------------------------------
E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de>
Date: 27-Sep-01
Time: 16:51:55
Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg
"Angewandte Statistik"
Universität Dortmund, 44221 Dortmund
Tel.: +49-231-755-5903  FAX: +49-231-755-4387
----------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list