[英]controlling raster plot legend labels to display specified breaks value in r
I would like to hide some breaks value in the legend labels only displaying some specified value like min value or maxvalue. 我想在图例标签中隐藏一些中断值,只显示一些指定值,如最小值或最大值。
library(raster)
r1 <- r2 <- r3 <- raster(ncol=10, nrow=10)
r1[] <- runif(ncell(r1))
n<-10
brks<-seq(minValue(r1),maxValue(r1),0.05)
plot(r1,breaks=brks,col=gray(seq(0,1,length=n)) )
The length of brks is 20, but I want to hide some values of brks in the legend labels and keep colors divided by brks. brks的长度是20,但是我想在图例标签中隐藏一些brk值,并保持颜色除以brks。
Questions: 问题:
How to display minvalue and maxvalue and hide the other value ?(same as strech render in arcmap ) 如何显示minvalue和maxvalue并隐藏其他值?(与arcmap中的strech渲染相同)
How to display some specified value ? 如何显示一些指定值? Pls make sure the brks is still working.
请确保brks仍在工作。
The plot method for raster
objects takes an argument axis.args
which gives you some control over the color table's annotation. raster
对象的绘图方法采用参数axis.args
,它可以控制颜色表的注释。
With your data, do something like this (and for more see the "Example" section of the help page returned by help("plot", package="raster")
: 使用您的数据,执行以下操作(有关更多内容,请参阅帮助返回的帮助页面的“示例”部分
help("plot", package="raster")
:
## Find the min and max z-values
rng <- range(r1[])
## Construct a list of arguments to be used for the color table
arg <- list(at=rng, labels=round(rng, 4))
## Pass them in to your call to plot
plot(r1,breaks=brks,col=gray(seq(0,1,length=n)), axis.args=arg)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.