내가 txt 파일에서이 데이터를 내가 (검은 색 사각형없이) 히트 맵을 구축플롯은 사각형 4 점 ggplot의 히트 맵에 주어진
"people","1","2","3","4","5","6","7","8","9","10","11","12"
"Ej1",0,0,0,0,0,0,0,0,0,0,0,0
"Ej2",0,0,1,1,1,1,1,1,0,0,0,0
"Ej3",0,0,0,0,0,0,1,0,0,0,0,0
"Ej4",0,1,1,1,0,0,1,1,0,0,0,1
"Ej5",1,1,1,1,1,1,1,1,0,0,0,1
"Ej6",1,1,1,1,0,1,1,1,0,0,1,1
"Ej7",1,1,1,1,1,1,1,1,0,0,0,0
"Ej8",0,0,0,1,1,1,0,0,0,0,0,0
"Ej9",0,0,1,1,1,1,1,1,0,0,0,0
"Ej10",0,0,0,1,1,1,1,0,0,0,0,0
"Ej11",0,0,0,0,1,0,0,0,0,1,1,0
"Ej12",0,0,1,1,1,0,0,0,0,1,1,1
"Ej13",0,1,1,1,0,0,0,1,1,1,1,1
"Ej14",1,1,0,0,0,0,0,1,1,1,0,1
"Ej15",0,0,0,0,0,0,0,1,1,1,1,1
"Ej16",0,0,0,0,0,0,0,1,1,1,1,1
(fruits2612e.txt)이 코드
library(reshape2)
library(ggplot2)
library(scales)
library(plyr)
data <- read.csv("fruits2612e.txt", head=TRUE, sep=",")
data$people <- factor(data$people,levels=rev(data$people))
data.m = melt(data)
#data.m <- ddply(data.m, .(variable), transform, rescale = rescale(value))
data.m[,"rescale"]<-rescale(data.m[,"value"],to=c(0,1))
fewer.labels <- c("Ej16","Ej15","Ej14","Ej13","Ej12","Ej11","Ej10","Ej9","Ej8","Ej7","Ej6","Ej5","Ej4","Ej3","Ej2","Ej1")
p <- ggplot(data.m, aes(variable, people)) +
geom_tile(aes(fill = rescale), colour = "white") +
scale_y_discrete(labels=fewer.labels) +
scale_fill_gradient(low = "red", high = "green") +
theme(axis.text=element_text(size=8))
를 사용하여이
는 지금은 히트 맵에 검은 색 사각형을 추가하기 위해 노력하고있어,하지만 좌표는 어떻게 찾을 수 없습니다
maxR<-c(topLeftx,topLefty,botRightX,botRightY)
[1] 5 1 7 8
내 자신의 조언에 따라 93,578,776,는
'annotate' 함수를보고'geom = 'rect''가 해결책을 제시하는지 조사해야합니다. –
도움이 될 수 있습니다 : http://stackoverflow.com/questions/22024641/how-to-add-bounding-box-to-a-specific-area-in-ggplot2-heatmap – KFB
정말 고마워요! – user3437823