2016-08-11 2 views
0

여기에 내가 그들 중 하나를 플롯하기 위해 측면 5 히트 맵 측면을 갖고 싶어 내 데이터 몇 개의 히트 맵을 가까이에서 어떻게 플롯 할 수 있습니까?

data <- structure(list(name1 = structure(1:10, .Label = c("A", "B", "C", 
"D", "E", "F", "G", "H", "I", "J"), class = "factor"), value1 = c(1.251, 
-1.018, -1.074, -1.137, 1.018, 1.293, 1.022, -1.008, 1.022, 1.252 
), name2 = structure(1:10, .Label = c("K", "L", "M", "N", "O", 
"P", "Q", "R", "S", "T"), class = "factor"), value2 = c(-1.005, 
1.694, -1.068, 1.396, 1.646, 1.016, 1.471, -1.609, 1.149, 1.212 
), name3 = structure(c(6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L 
), .Label = c("AA", "AB", "AC", "AD", "AF", "V", "W", "X", "Y", 
"Z"), class = "factor"), value3 = c(1.174, -1.077, 1.274, -1.75, 
1.13, -1.018, -1.203, 1.054, 1.122, 1.151), name4 = structure(c(1L, 
3L, 2L, 5L, 4L, 8L, 6L, 7L, 9L, 10L), .Label = c("AG", "AK", 
"AN", "AY", "AZ", "BA", "BB", "BC", "BF", "BM"), class = "factor"), 
    value4 = c(1.034, 1.287, 1.205, -1.2, 2.412, 2.397, -1.054, 
    -1.063, -1.005, 1.08), name5 = structure(c(3L, 5L, 4L, 9L, 
    10L, 8L, 1L, 6L, 7L, 2L), .Label = c("DZ", "FM", "GF", "GN", 
    "GT", "LI", "NO", "RF", "TG", "TQ"), class = "factor"), value5 = c(1.339, 
    1.051, 1.368, 1.17, -1.167, -1.138, -1.031, 1.173, 1.196, 
    1.13)), .Names = c("name1", "value1", "name2", "value2", 
"name3", "value3", "name4", "value4", "name5", "value5"), class = "data.frame", row.names = c(NA, 
-10L)) 

입니다. 난 그저 내가 라벨 X와 Y

모두

의 색상과 굵은 텍스트를 하나의 그림 에 모두 5를 넣고도 변경 할 수 있도록하려면,하지만 다음

ggplot(data, aes(x = 1, y = name1, fill = value1)) + 
    geom_tile() 

을 수행 할 수 있습니다 어떠한 제안 ? 내가 제안

답변

4

한 가지 방법은 당신이 cowplot 패키지를 사용할 수 있습니다 gridExtra

plot1<- ggplot(data, aes(x = 1, y = name1, fill = value1)) + 
    geom_tile()+ 
    theme(legend.position="none") 

plot2<- ggplot(data, aes(x = 1, y = name2, fill = value2)) + 
    geom_tile()+ 
    theme(legend.position="none") 

plot3<- ggplot(data, aes(x = 1, y = name3, fill = value3)) + 
    geom_tile()+ 
    theme(legend.position="none") 

plot4<- ggplot(data, aes(x = 1, y = name4, fill = value4)) + 
    geom_tile()+ 
    theme(legend.position="none") 

plot5<- ggplot(data, aes(x = 1, y = name5, fill = value5)) + 
    geom_tile() + 
    theme(legend.position="none") 

grid.arrange(plot1, plot2,plot3,plot4,plot5, ncol=5) 

enter image description here

1

라는 이름의 패키지를 설치해야 @ 데이비드 LeBauer에 의해 주어진 접근 방식을 사용하는 것입니다

plot_grid()

이러한 플롯의 레이블링을 쉽게하려면

require(cowplot) 
plot1 <- ggplot(data, aes(x = 1, y = name1, fill = value1)) + geom_tile() 
plot2 <- ggplot(data, aes(x = 1, y = name1, fill = value1)) + geom_tile() 
plot_grid(plot1, plot2, align='v', labels=c('name1', 'name2')) 

enter image description here

관련 문제