【问题标题】:Define margins of PDF used for boxplot rendering定义用于箱线图渲染的 PDF 边距
【发布时间】:2017-03-08 08:36:58
【问题描述】:

当我在 R 中的 PDF 设备上渲染箱线图时,除了图形之外,还有一个很大的空白区域,尤其是在我打算减少的顶部。

我的脚本基本上就是:

data <- read.csv("input.csv")
pdf(file="output.pdf", width=4, height=5)
boxplot(data, xlab="input graphs", ylab="vertex count")

这会导致类似:

灰色轮廓表示文档的结尾。

我尝试使用https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/par.html 中描述的 par 属性“mar”和“mai”,但没有效果。

boxplot(data, mar=c(0,0,0,0=, mai=c(0,0,0,0))

您对我如何获得空白控制有什么建议吗?我希望外部空白为零,因为生成的图形将在 Latex 环境中使用,该环境本身提供足够的间距。我正在使用 Ubuntu 作为操作系统。

【问题讨论】:

  • 请检查this post,如果同意我将作为重复关闭。
  • 如果您不知道,您可以使用 LATEX 中的 trimgraphicx 包来裁剪 PDF。如果你知道,我会删除这个。
  • 感谢 Latex 包的提示 :) 确实,该主题与另一个主题很接近。不过我更喜欢这里收到的答案。

标签: r pdf plot


【解决方案1】:

pdf 之后定义mar。试试这个作为例子

pdf(file = "test.pdf", width = 5, height = 5)
par(mar = c(5, 5, 0.05, 0.05))
set.seed(42)
plot(rnorm(20))
dev.off()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 2021-07-28
    • 2019-12-28
    相关资源
    最近更新 更多