2016-10-31 6 views
1

に追加しました。インセットを印刷し、ggplotsのプロットからグリッドを作成することができました。しかし、私は左のプロットと右のフルサイズの2つのプロットと "インセット"の他のグリッドを作成することはできません。ggplot2 grid.arrangeの2つのプロットを2番目のインセットと共にR

a_plot <- ggplot(cars, aes(speed, dist)) + geom_line() 

#The inset 
print(a_plot);print(a_plot, vp = vp) 

enter image description here

# the Grid 
lay <- rbind(c(1,1,1,2,2,2), 
      c(1,1,1,2,2,2), 
      c(1,1,1,2,2,2), 
      c(1,1,1,2,2,2)) 
grid.arrange(a_plot, a_plot,layout_matrix = lay) 

enter image description here

しかし、私はこれを持っているしたいと思います:

enter image description here

私はこれをどのように行うことができますか?

これは私がthisを試してみました

grid.arrange(a_plot, a_plot,print(a_plot, vp = vp),layout_matrix = lay) 

動作しません、それはどちらか動作しませんでした。

+0

私はインセットを作成するためにこれを使用することができるよが、その後、グリッド上で、それを入れていない... –

答えて

1
a_plot <- ggplot(cars, aes(speed, dist)) + geom_line() 
b_plot <- a_plot + annotation_custom(grob = rectGrob(), 
         xmin = 15, xmax = Inf, ymin=-Inf, ymax=25) 


grid.arrange(a_plot, b_plot, ncol=2) 

enter image description here

+0

b_plot < - a_plot + coord_cartesian()+ annotation_custom(グロブ= ggplotGrob (a_plot)、xmin = -90.2、xmax = Inf、ymin = -Inf、ymax = -0.8) オブジェクトがマップの場合、 'coord_cartesian()'が必要かもしれません。 'reacGrob()'の代わりに 'ggplotGrob()'を使います。 –

関連する問題