删除 PDF 输出中条形周围的空格 [英] Remove spaces around bars in PDF output
问题描述
我有一个条形图:
> 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
- 通过
quartz.save('file.pdf', type = 'pdf')
或 - 通过
pdf('file.pdf', type = 'pdf')
后跟barplot(…)
- via
quartz.save('file.pdf', type = 'pdf')
or - via
pdf('file.pdf', type = 'pdf')
followed bybarplot(…)
输出如下:
条形之间有清晰可辨的线条.不幸的是,在我的情况下,这不仅仅是审美上的麻烦:我正在绘制 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屋!