Remove spaces around bars in PDF output
plot, r
Solution
This should work:
barplot(data, space = 0, col = 'gray', border = 'gray')
EDIT: Extended answer.
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()
Problem
I have a bar plot: ``` > data = c(1, 5, 3, 4) > barplot(data, space = 0, col = 'gray', border = 0) ``` On OS X, using the default driver (Quartz), this looks like this: Notice how there is no space between the bars. However, when exporting the figure to PDF, either - via `quartz.save('file.pdf', type = 'pdf')` or - via `pdf('file.pdf', type = 'pdf')` followed by `barplot(…)` The output looks like this: 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. Is there a way to get rid of the lines in the output? Preferably when using the `pdf` device rather than PDF `quartz` output?