I would use Inkscape for something like John's diagrams. I presume you want a programmable solution Daniel, but I'm not clear why? I've used R in that way when I've needed to, but that hasn't been often.