本文介绍了我怎样才能将几个地图靠近在一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这里是我的数据 data< - structure(list(name1 = structure(1:10,.Label = c(A,B,C,D,E,F,G,H,I,J),class =因子),值1 = c(1.251, -1.018,-1.074,-1.137,1.018,1.293,1.022,-1.008,1.022,1.252 ),名称2 =结构(1:10,。标签= c(K,L,M,N,O,P,Q,R,S,T =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 ),。标签= c(AA,AB,AC,AD,AF ,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.1220,1.1571),name4 =结构(c(1L, 3L,2L,5L,4L,8L,6L,7L,9L,10L),标签= c( AG,AK,AN,AY,AZ,BA,BB,BC,BF,BM), , value4 = c(1.034,1.287,1.205,-1.2,2.412,2.339,-1.054, -1.063,-1.005, 1.08),name5 =结构(c(3L,5L,4L,9L, 10L,8L,1L,6L,7L,2L),。标签= c(DZ,FM ,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.1976, 1.13)),.Names = c(name1,value1,name2,value2,name3,value3,name4,value4,name5,value5),class =data.frame,row.names = c(NA, -10L )) 我想要有5个热量图并排,他们。我可以简单地执行以下操作: $ g $ p $ ggplot(data,aes(x = 1,y = name1,fill = value1))+ geom_tile() 但是,我希望能够将所有5个一个数字,还可以改变颜色和粗体标签的文字X和Y 有什么建议吗? 给出的方法,您需要安装名为 gridExtra 的软件包 pre $ plot1 geom_tile + 主题(legend.position =none) plot2 geom_tile()+ theme(legend.position =none) plot3 geom_tile()+ theme(legend.position =none) plot4 geom_tile()+ theme(legend.position =none) plot5 geom_tile()+ theme(legend.position =none) grid.arrange(plot1,plot2,plot3,plot4,plot5 ,ncol = 5) Here is my data 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))i want to have 5 heatmaps side by sidein order to plot one of them. I can simply do the following ggplot(data, aes(x = 1, y = name1, fill = value1)) + geom_tile()however, I want to be able to put all 5 of them in one figureand also change the color and bold the text of the label both X and Yany suggestion ? 解决方案 One way I propose is to use approach given by @David LeBaueryou need to install package named gridExtraplot1<- 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) 这篇关于我怎样才能将几个地图靠近在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 19:46