代码之家  ›  专栏  ›  技术社区  ›  jay.sf

如何优化布局中的多行文字坐标和图例间距?

  •  0
  • jay.sf  · 技术社区  · 7 年前

    “文本”的标题奇怪地位于不同的y坐标上,尽管它们的定义完全相同,但是 par 它们是一样的。

    除此之外,我想让房间里的空间稍微窄一点 legend , cex 不会有任何帮助的。

    enter image description here

    我可以在里面加一些空间     -风格(参见 MARK 在代码中)看起来更好,但不会固定间距:

    enter image description here

    有人知道怎么处理吗(没有额外的包裹)?

    输出 传奇 应该是这样的:

    enter image description here

    代码生成图

    # pdf("test.pdf", width=8, height=4)
    
    layout(matrix(c(1, 3, 2, 3), ncol=2), heights=c(4, 1.5))
    
    par(mai=c(0, .5, .5, .25))
    plot(1:10)
    mtext(bquote(bold("Linear points")), 3, 0, cex=.9, adj=0, padj=-.3)
    
    par(mai=c(0, .5, .5, .25))
    curve(x^2)
    mtext(bquote(bold("A curve")), 3, 0, cex=.9, adj=0, padj=-.3)
    
    par(mai=c(0, 0, .375, 0))
    plot.new()
    legend("center", legend=c("The quick", "brown fox", "jumps over",
                              "the lazy dogs",
                              # expression(paste("    ", alpha~"=5%")),  # MARK
                              expression(alpha~"=5%"),
                              "DF=Dgs. of freedom"),
           lty=c(rep(1, 4), rep(NA, 2)), bg="white", col=1:4,
           xpd=TRUE, pt.cex=1.1, horiz=TRUE, cex=.7)
    
    # dev.off()
    
    0 回复  |  直到 7 年前