Inspired by the excellent BeanShell example, here is the same thing in Groovy (but displaying in a Swing window rather than writing to a file):
Here is the result:
Or if you prefer Line Charts:
And the result looks like:
Additionally, you might have a look at the GroovyChart library which provides a dedicated builder interface for building charts.