[R] unequal bins in filled.contour

Dan Carpenter d.carpenter at nhm.ac.uk
Wed Aug 31 16:33:20 CEST 2011


Hello,

I am trying to plot SADIE red-blue plots of cluster indicies using
filled.contour.  I want a plot which only has three bins for the data:
<-1.5, -1.5 - 1.5, >1.5, but I am having trouble getting there.

example
  X1   X2  X3   X4 X5
1 -5 -4.5 1.0  4.5  6
2 -3 -2.0 1.2 -1.0  3
3  0  0.0 0.0 -0.5 -1
4 -2 -3.0 1.0  1.5  3
5 -6 -2.0 0.5  3.0  2
example<-as.matrix(example)
filled.contour(example)
filled.contour(example,levels=seq(min(example),max(example)),
color.palette=colorRampPalette(c("blue","white","red")))

I tried this to get just three bins, but data outside that range doesn't
plot.
seq(-4.5,4.5,by=3)
[1] -4.5 -1.5  1.5  4.5
filled.contour(example, levels=seq(-4.5,4.5,by=3),
color.palette=colorRampPalette(c("blue","white","red")))

I increased the range but I now have two shades of red and blue, when
what I really want is one shade of each
seq(-7.5,7.5,by=3)
[1] -7.5 -4.5 -1.5  1.5  4.5  7.5
filled.contour(example, levels=seq(-7.5,7.5,by=3),
color.palette=colorRampPalette(c("blue","white","red")))

Is there a way to either
1) Create unequal bins, so all data below -1.5 is blue and all data
above 1.5 red
Or
2) colour more than one bin the same shade

Many thanks,
Dan.

Dr Dan Carpenter | Post-doctoral Research Assistant | Soil Biodiversity
Group | Entomology Department | Natural History Museum | London | SW7
5BD | 0207 942 5208 | d.carpenter at nhm.ac.uk



More information about the R-help mailing list