Bugfree code, generates complete graphs

plot.R now uses a function, so I don't repeat myself and the code is
easier to maintain.