2014-11-23 40 views
1

感謝this question我知道如何將相同寬度的地塊彼此相鄰對齊,但我想讓我的第一個地塊比第二個地塊寬得多(儘管相同的高度,第二個情節需要是正方形的)。使用knitr對齊彼此相鄰的不同寬度的地塊

This post與我玩一個想法,玩陰謀layout。因此,這裏是我的代碼:

\documentclass{article} 
\begin{document} 

Side by side images: 

\begin{figure}[htpb] 
<<test, echo=FALSE, out.width='1\\linewidth'>>= 
par(mar=c(2,2,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3) 
layout(t(matrix(c(1,2))), widths=c(10,2), heights=c(2,2), TRUE) 
plot(1:100) 
plot(1:10) 
@ 
\end{figure} 
Ta da! 
\end{document} 

,這裏是PDF格式,我得到:

enter image description here

所以,如果這是正確的做法,我怎樣才能在頂部和擺脫空間底部? 如果不是,那是正確的?

在此先感謝。

+0

你只需要調整寬度和高度'layout(t(matrix(c(1,2))),widths = c(8,2),heights = 4,TRUE)' – rawr 2014-11-23 18:05:33

+0

@rawr Thanks for您的評論,我忘了提及我需要我的第二個陰謀是方形的。我的確嘗試過寬度和高度,但我總是在頂部和底部獲得這個額外的空間。 – dariaa 2014-11-23 18:30:31

回答

2
fig.width=8, fig.height=2 

應該工作。我通常完全避免out.width