在图中概述统计上显着的像素(热图)

时间:2017-12-19 14:32:45

标签: r plotly

在plotly的热图中,是否可以勾勒出特定的像素?在下面的小型可重复示例中,我想知道我是否可以使用最后定义的矩阵,称为“重要”,将黑色轮廓(带lwd=2)添加到所有像素,并具有相应的值1''重要':

library(plotly)
library(RColorBrewer)

m1 <- matrix(c(
-0.0024, -0.0031, -0.0021, -0.0034, -0.0060, -1.00e-02, -8.47e-03, -0.0117, -0.0075, -0.0043, -0.0026, -0.0021,
-0.0015, -0.0076, -0.0032, -0.0105, -0.0107, -2.73e-02, -3.37e-02, -0.0282, -0.0149, -0.0070, -0.0046, -0.0039,
-0.0121, -0.0155, -0.0203, -0.0290, -0.0330, -3.19e-02, -1.74e-02, -0.0103, -0.0084, -0.0180, -0.0162, -0.0136,
-0.0073, -0.0053, -0.0050, -0.0058, -0.0060, -4.38e-03, -2.21e-03, -0.0012, -0.0026, -0.0026, -0.0034, -0.0073,
-0.0027, -0.0031, -0.0054, -0.0069, -0.0071, -6.28e-03, -2.88e-03, -0.0014, -0.0031, -0.0037, -0.0030, -0.0027,
-0.0261, -0.0223, -0.0216, -0.0293, -0.0327, -3.17e-02, -1.77e-02, -0.0084, -0.0059, -0.0060, -0.0120, -0.0157,
 0.0045,  0.0006, -0.0031, -0.0058, -0.0093, -9.20e-03, -6.76e-03, -0.0033,  0.0002,  0.0045,  0.0080,  0.0084,
-0.0021, -0.0018, -0.0020, -0.0046, -0.0080, -2.73e-03,  7.43e-04,  0.0004, -0.0010, -0.0017, -0.0022, -0.0024,
-0.0345, -0.0294, -0.0212, -0.0194, -0.0192, -2.25e-02, -2.05e-02, -0.0163, -0.0179, -0.0213, -0.0275, -0.0304,
-0.0034, -0.0038, -0.0040, -0.0045, -0.0059, -1.89e-03,  6.99e-05, -0.0050, -0.0114, -0.0112, -0.0087, -0.0064,
-0.0051, -0.0061, -0.0052, -0.0035,  0.0012, -7.41e-06, -3.43e-03, -0.0055, -0.0020,  0.0016, -0.0024, -0.0069,
-0.0061, -0.0068, -0.0089, -0.0107, -0.0104, -7.65e-03,  2.43e-03,  0.0008, -0.0006, -0.0014, -0.0021, -0.0057,
 0.0381,  0.0149, -0.0074, -0.0302, -0.0550, -6.40e-02, -5.28e-02, -0.0326, -0.0114,  0.0121,  0.0367,  0.0501,
-0.0075, -0.0096, -0.0123, -0.0200, -0.0288, -2.65e-02, -2.08e-02, -0.0176, -0.0146, -0.0067, -0.0038, -0.0029,
-0.0154, -0.0162, -0.0252, -0.0299, -0.0350, -3.40e-02, -2.51e-02, -0.0172, -0.0139, -0.0091, -0.0119, -0.0156),
nrow = 15, ncol = 12, byrow=TRUE)

# palette definition
palette <- colorRampPalette(c("darkblue", "blue", "white", "red", "darkred"))

# find max stretch value
zmax1 = max(abs(m1))

plot_ly(
x = c(format(seq(as.Date('2000-10-01'), as.Date('2001-09-30'), by='month'), "%b")), 
y = rev(c("TH1", "IN1", "IN3", "GL1", "LH1", "ED9", "TC1", "TC2", "TC3", "UT1", "UT3", "UT5", "GC1", "BC1", "WC1")), ,
z = m1, colors = palette(50), type = "heatmap", width = 700, height = 600, zauto = FALSE, zmin = -1 * zmax1, zmax = zmax1
)

# Can this matrix somehow be used to outline pixels in the heatmap that are equal to one?
# (In this example, the outline pattern will look like a checker board)
significant <- matrix(rep(c(0,1), times=nrow(m1) * ncol(m1) / 2), nrow = 15, ncol = 12)

0 个答案:

没有答案
相关问题