Hi Eric, you can use an annotate-layer, eg ind<-which(sig>0,arr.ind = T) ggplot(m1.melted, aes(x = Month, y = Site, fill = Concentration), autoscale = FALSE, zmin = -1 * zmax1, zmax = zmax1) + geom_tile() + coord_equal() + scale_fill_gradient2(low = "darkred", mid = "white", high = "darkblue", midpoint = 0) +annotate("rect",ymin=ind[,"row"]-.5,ymax=.5+ind[,"row"], xmin=-.5+ind[,"col"],xmax=.5+ind[,"col"],colour="red", size=.5, linetype=1, fill=NA)
Cheers Am 20.12.2017 um 01:32 schrieb Morway, Eric: > library(ggplot2) > library(RColorBrewer) > library(reshape2) > > 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, > dimnames = list(rev(c("TH1", "IN1", "IN3", "GL1", "LH1", "ED9", "TC1", > "TC2", "TC3", "UT1", "UT3", "UT5", "GC1", "BC1", "WC1")), > c(format(seq(as.Date('2000-10-01'), > as.Date('2001-09-30'), by='month'), "%b")))) > > # palette definition > palette <- colorRampPalette(c("darkblue", "blue", "white", "red", > "darkred")) > > # find max stretch value > zmax1 = max(abs(m1)) > > m1.melted <- melt(m1) > names(m1.melted) <- c('Site','Month', 'Concentration') > > # Set up an example matrix with binary code for which results (pixels) are > significant > set.seed(4004) > sig <- matrix(round(abs(rnorm(15*12)/3)), nrow = 15, ncol = 12) > > ggplot(m1.melted, aes(x = Month, y = Site, fill = Concentration), autoscale > = FALSE, zmin = -1 * zmax1, zmax = zmax1) + > geom_tile() + > coord_equal() + > scale_fill_gradient2(low = "darkred", > mid = "white", > high = "darkblue", > midpoint = 0) -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistrasse 52 building W 34 20246 Hamburg Phone: +49 (0) 40 7410 - 58243 Fax: +49 (0) 40 7410 - 57790 Web: www.uke.de/imbe -- _____________________________________________________________________ Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Martina Saurin (komm.) _____________________________________________________________________ SAVE PAPER - THINK BEFORE PRINTING ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.