Factored out some common graphing code.
Merge pull request #403 from hjoliver/reuse-some-common-graph-code

Factored out some common graphing code.