Refactor which partitions are drawn into it's own class and alter function calls accordingly. Separate marking if a nuclei should be drawn and actually drawing it.
To get round the issue with the key not being drawn correctly if Z<=8, in these cases use the key size to set the y size of the canvas.
Add varaible to represent the width of the canvas, move overall size variables to a more general place and draw grid over the entire canvas.
Move the BoundingBox line to the top of the EPS now that we know the size before starting to write the file.
Only set the key scale if the key is going to be drawn.
Initialise some string for good practive and remove repeated code by creating a for loop.
Some important formatting and there is no need to exit if we can't write the option file, just say that we haven't written it.