Q:

R - barplot | How to control space and width of bars

I want the bars to be close to each other, but not adjacent (beside=FALSE), and I want also the bars to be slightly thin. I have played around with space and width but I am not getting my desired results.
I prefer to stay with barplot function instead of using ggplots, but if there is no way thought it, that is ok.
This is the expected barplot (edited manually from the obtained):

And this is the obtained:

Code Used:
jpeg("03.Annotation.Distribution.DMRs.All.jpeg")
bp1 = barplot(ann[,1:2], ylim=c(0,1.1), col=ann[,3], beside=FALSE, space=10, 
              names.arg=c("Genome","DMRs"), las=3, xlab="Group", ylab="Frequency", 
              main="Annotation distribution on DMRs")
legend("top",legend=rownames(ann)[7:1], fill=ann[7:1,3], bty="n", horiz=FALSE)
dev.off()

Thankyou!

A:

The width of the bars has to do with the size of the device you're using. You can hack the spacing by setting up a new plot window based on your data and add to it, ie, make the xlim larger than you need.
jpeg('./tmp.jpg', width = 250, height = 480, bg = 'grey90')
plot.new()
plot.window(c(0,6), c(0,1))
with(mtcars,
     barplot(prop.table(table(gear, vs), 2), col = 1:3, add = TRUE,
             legend.text = unique(gear), xlab = 'vs'))
dev.off()

