[racket] Plot to png

From: Thomas Chust (chust at web.de)
Date: Mon Jan 17 08:47:04 EST 2011

2011/1/17 Milan Markovic <zivotinja at gmail.com>:
> [...]
> I was wondering if I could save a plot directly to an image file without
> having to "fish" it out of the REPL and right click.
> [...]

Hello Milan,

plot views support the convertible protocol. Try something like this:

  #lang racket/base
  (require file/convertible plot)
  (convert (plot (line sin)) 'png-bytes)

The result of this call is a byte string that can be written to a PNG


When C++ is your hammer, every problem looks like your thumb.

Posted on the users mailing list.