将数值矩阵映射为栅格图

Posted junjunang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将数值矩阵映射为栅格图相关的知识,希望对你有一定的参考价值。

  

require(grDevices) # for colours
x <- y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))
image(z = z <- cos(r^2)*exp(-r/6), col = gray((0:32)/32))
image(z, axes = FALSE, main = "Math can be beautiful ...",
xlab = expression(cos(r^2) * e^{-r/6}))
contour(z, add = TRUE, drawlabels = FALSE)

# Volcano data visualized as matrix. Need to transpose and flip
# matrix horizontally.
image(t(volcano)[ncol(volcano):1,])

# A prettier display of the volcano
x <- 10*(1:nrow(volcano))
y <- 10*(1:ncol(volcano))
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
contour(x, y, volcano, levels = seq(90, 200, by = 5),
add = TRUE, col = "peru")
axis(1, at = seq(100, 800, by = 100))
axis(2, at = seq(100, 600, by = 100))
box()
title(main = "Maunga Whau Volcano", font.main = 4

 

 

 

 

以上是关于将数值矩阵映射为栅格图的主要内容,如果未能解决你的问题,请参考以下文章

数值计算矩阵浅析

R语言将字符串矩阵转化为数值型矩阵

特征工程

MATLAB实现矩阵里数值的大小对应颜色的深浅

MATLAB | 有关数值矩阵颜色图及颜色列表的技巧整理

颜色渐变的柱状图