パッチワークパッケージ(GitHub - thomasp85/patchwork: The Composer of ggplots)は便利ですね。
library(tidyverse)library(patchwork) data("author",package ="ca") author_t <- as_data_frame(author)%>% mutate(title=rownames(author))%>% gather(alphabet,count,-title) alphabet_t <- group_by(author_t,alphabet)%>% summarise(count=sum(count)) p1<-ggplot(author_t,aes(x=title,y=alphabet,fill=count))+ geom_tile()+ scale_fill_continuous(low="white",high="black")+ theme(legend.position ="left",axis.text.x = element_text(angle=90), plot.margin= unit(c(1,0,1,1),"lines")) p2 <-ggplot(alphabet_t,aes(x=alphabet,y=count))+ geom_col(fill="white",colour="black")+ coord_flip()+ theme(axis.text.y = element_blank(),axis.ticks.y = element_blank(), plot.margin= unit(c(1,1,1,-1),"lines"))+ xlab("")(p1|p2)