I have model plotted in R

base<- raster("example.tif") plot(base)

image I'd like to change value (0,5,10,15,20,25)

breakpoints<-c("0,5,10,15,20,25") plot(base,break=breakpoints)

Error in .rasterImagePlot(object, col = col, xlab = xlab, ylab = ylab, : object 'breakpoints' not found

I'd like make ramp(default colour)

  • Question: Please look at the colour legend in the attached image. This image was plotted in ferret program, which has different breaks, like 0-3 with 0.5 interval, 3-9 with 3 interval, 9-10 with 1 interval, 10-20 with 2 interval and 20-70 with 50 interval. The legend scale was uniformly graduated but labelled as per breaks given. Can we get such legends in R 'Raster - plot'? or any other packages in R? Thanks :) Karnan C ![Satellite chlorophyll](i.stack.imgur.com/uCXYN.png) – Karnan May 16 '19 at 7:36

Using my base raster:

base<- raster("test.tif")

I got:

enter image description here

For your breakpoints:

plot(base, col=terrain.colors(6), breaks=breakpoints)

enter image description here

With help(plot), raster option, you can see examples of other descriptions for this R command.

Another plot option:

plot(base, col=colorRampPalette(c("red", "orange", "blue"))(6), breaks=breakpoints)

where I have:

enter image description here

Editing Note:

I know that the values of my raster are between 0-50. I can do this:

plot(base, col=colorRampPalette(c("red", "orange", "blue"))(7), breaks=breakpoints)

or this:

colors<-c("red", "orange", "blue","green","yellow","cyan","magenta")
plot(base, col=colors, breaks=breakpoints)

enter image description here

  • For customized colors: "A color palette, i.e. a vector of n contiguous colors generated by functions like rainbow, heat.colors, topo.colors, bpy.colors or one or your own making, perhaps using colorRampPalette’. If none is provided, ‘rev(terrain.colors(255))’ is used unless ‘x’ has a 'color table'" – xunilk Mar 29 '15 at 12:42
  • Please, edit your question and put the complete code that you are using. – xunilk Mar 29 '15 at 13:49
  • You have an error here: breakpoints<-c("0,5,10,15,20,25"). It is: breakpoints<-c(0,5,10,15,20,25) – xunilk Mar 29 '15 at 14:09
  • Because your original values are between 0-60 and now, you have new labels values produced by your breakpoints. Can you change the aspect of the legend? – xunilk Mar 29 '15 at 14:27
  • can >25 same color with 25 ? and how to change min color value to max color value? like this – Yax Mar 29 '15 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.