r - 在图像 {graphics} 中添加颜色图例

标签 r colors legend

在这个例子中,我有一张带有颜色的图像,我想知道我们是否可以添加颜色图例。例如:[8:10] 中带有 z 的点具有红色等等。

x=runif(500,0,5)
y=runif(500,0,5)
z=floor(runif(500, 1,10)) 
xyz=data.frame(x,y,z)
library(MBA)
mba.int <- mba.surf(xyz, 300, 300, extend=T)$xyz.est
image(mba.int, xaxs="i", yaxs="i")

谢谢。 enter image description here

最佳答案

感谢@user20650,答案是:

fields::image.plot(mba.int, col = heat.colors(12))

enter image description here

关于r - 在图像 {graphics} 中添加颜色图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28301514/

相关文章:

html - 为什么我的字体颜色不起作用

legend - 在 dc.js 中为饼图添加图例

MATLAB:为图例中的文本分配多种颜色

r - 如何在 geom_tile 中设置单独的列宽(在 ggplot2 中)

opencv - 在 HSV 颜色空间中定义黑色区域

node.js - 检测 Image Nodejs OpenCV 特定区域的颜色

r - 如何阻止 R ggplot 在我的图例中显示 "a"作为符号?

r - dplyr arrangement 不按组排列

r - 如何在以下代码中获得 x 轴标签的 45 角

R:lubridate 返回 NA – 意外地