【问题标题】:Align plots of different widths next to each other with knitr使用knitr将不同宽度的图对齐
【发布时间】:2014-11-23 17:50:27
【问题描述】:

感谢this question 我知道如何将相同宽度的图彼此对齐,但我希望我的第一个图比第二个宽得多(但高度相同,第二个图需要是方形的)。

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:

所以如果这是正确的方法,我怎样才能摆脱顶部和底部的空间? 如果不是,那正确的是什么?

提前致谢。

【问题讨论】:

  • 你只需要调整宽度和高度也许layout(t(matrix(c(1,2))), widths=c(8,2), heights=4, TRUE)
  • @rawr 感谢您的评论,我忘了提到我的第二个情节需要是正方形的。我确实尝试过使用宽度和高度,但我总是在顶部和底部获得额外的空间。

标签: r latex knitr


【解决方案1】:
fig.width=8, fig.height=2

应该可以。我通常完全避免out.width

【讨论】:

    猜你喜欢
    • 2012-05-21
    • 1970-01-01
    • 2017-04-17
    • 2013-02-28
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2019-09-20
    相关资源
    最近更新 更多