删除 PDF 输出中条形周围的空格 [英] Remove spaces around bars in PDF output

查看:47
本文介绍了删除 PDF 输出中条形周围的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个条形图:

> data = c(1, 5, 3, 4)
> barplot(data, space = 0, col = 'gray', border = 0)

在 OS X 上,使用默认驱动程序 (Quartz),如下所示:

On OS X, using the default driver (Quartz), this looks like this:

注意条形之间如何没有空间.但是,将图形导出为 PDF 时,要么

Notice how there is no space between the bars. However, when exporting the figure to PDF, either

  1. 通过 quartz.save('file.pdf', type = 'pdf')
  2. 通过 pdf('file.pdf', type = 'pdf') 后跟 barplot(…)
  1. via quartz.save('file.pdf', type = 'pdf') or
  2. via pdf('file.pdf', type = 'pdf') followed by barplot(…)

输出如下:

条形之间有清晰可辨的线条.不幸的是,在我的情况下,这不仅仅是审美上的麻烦:我正在绘制 lot 像素细条,条之间的空间几乎与条本身一样大,这会发生变化对情节的深刻理解.

There are clearly discernible lines between the bars. Unfortunately, in my case this is more than just an aesthetic nuisance: I’m plotting a lot of pixel-thin bars, and the space between the bars is almost as big as the bars themselves, which changes the perception of the plot drastically.

有没有办法去掉输出中的行?最好使用 pdf 设备而不是 PDF quartz 输出?

Is there a way to get rid of the lines in the output? Preferably when using the pdf device rather than PDF quartz output?

推荐答案

这应该有效:

barplot(data, space = 0, col = 'gray', border = 'gray')

扩展答案.

如果你只是将边框的颜色定义为与填充相同的颜色,它应该可以工作.以下代码生成以下图:

If you just define the color of border to the same than the fill, it should work. Following code produces the plot below:

data = c(1, 5, 3, 4)
pdf('file.pdf') 
barplot(data, space = 0, col = 'gray', border = 'gray')
dev.off()

这篇关于删除 PDF 输出中条形周围的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆