How to represent the highest and lowest values ​​using <<?

I have a bitmap, and when I draw it, I got the legend as a rectangle. I am asked to capture the legend as such on this graph (two arrows below and above).

enter image description here

The colors in the triangles represent all values ​​above 15 and below -10. If triangles are difficult to put on a legend. Is it possible to simply put on the characters> <up to 15 AND 10 !.

    on the top > 15   and on the bottom < -10
library(raster)
r <- raster(nrows=10, ncols=10); r <- setValues(r, 1:ncell(r))
plot(r)
+4
source share
1 answer

, , , " -10" " 15". , .

rasterVis::levelplot:

# First, some fake data
r <- raster(matrix(runif(100, -20, 30), 10))

library(rasterVis)
levelplot(r, margin=FALSE, at=c(-Inf, seq(-10, 15, 2.5), Inf), 
          colorkey=list(at=seq(-12.5, 17.5, 2.5),
                        labels=c(expression(-infinity), 
                                 seq(-10, 15, 2.5), 
                                 expression(infinity)))
)

enter image description here

at levelplot , . , -Inf -10 , 2,5 , 15, Inf. at colorkey . -12,5 17,5. labels colorkey , . expression .

, . , 7 5 , 14 2:

library(RColorBrewer)
colr <- colorRampPalette(rev(brewer.pal(11, 'RdBu')))(14)[3:14]

col.regions:

levelplot(r, margin=FALSE, at=c(-Inf, seq(-10, 15, 2.5), Inf), 
      colorkey=list(at=seq(-12.5, 17.5, 2.5),
                    labels=c(expression(-infinity), 
                             seq(-10, 15, 2.5), 
                             expression(infinity))),
      col.regions=colr
)

enter image description here

+3

Source: https://habr.com/ru/post/1617509/


All Articles