2008-11-24

Simple GnuPLoTting

gnuplot is a very powerful and widely used interactive data plotting program. It can generate two-dimenational and three-dimensional surface plots, either on screen or print to files with a wide-array of supported formats. If you are not familiar with it, you can get an idea of its capabilities here
A new package, gnuplot.plt, is now available on planet which allows you to programmatically interact with gnuplot processes and generate plots on the fly. The package provides a simple interface that abstracts gnuplot's quirky syntax and takes care of data marshalling using temporary files.
Without further ado, here is to every computer scientist's favorite growth curves:

(require (planet vyzo/gnuplot))
(define gplot (gnuplot-spawn))
(define data 
  (gnuplot-data
   (build-list 90
     (lambda (x) 
       (let ((x (add1 (/ x 10.))))
         (list x (log x) (* x (log x)) (expt x 2) (expt 2 x)))))))
;; png output options
(define png '(png enhanced transparent font (str arial)))
;; on screen plot
(gnuplot-set gplot '(title (str "growth curves")))
(gnuplot-plot gplot 
  #:range '(() (1 1000))
  (gnuplot-item data '(using (seq: 1 1) title (str "x") with line))
  (gnuplot-item data '(using (seq: 1 2) title (str "log(x)") with line))
  (gnuplot-item data '(using (seq: 1 3) title (str "xlog(x)") with line))
  (gnuplot-item data '(using (seq: 1 4) title (str "x^2") with line))
  (gnuplot-item data '(using (seq: 1 5) title (str "2^x") with line)))
;; replot to png
(gnuplot-hardcopy gplot "/tmp/grow.png" #:term png)
;; redo with logscale
(gnuplot-set gplot '(logscale y))
(gnuplot-replot gplot)
(gnuplot-hardcopy gplot "/tmp/loggrow.png" #:term png)

2008-11-21

PLT Scheme v4.1.3

PLT Scheme version 4.1.3 is now available from

  http://plt-scheme.org/
This is a bug-fix release. Notable changes:
  • Web Server:
    • Documentation rewritten to separate servlet APIs and server extension APIs
    • HTTPS supported on the "plt-web-server" command-line with "--ssl" option
    • Stateless servlets supported in default configuration through 'stateless interface-version
    • `web-server/servlet-env' supports top-level servlets through #:servlet-path
    • Servlets are served from anywhere in the htdocs directory by default
    • A template system based on the Scribble syntax has been added, see web-server/templates in the documentation
    And many other internal modifications to make extension easier!
[Note that mirror sites can take a while to catch up with the new downloads.] Feedback Welcome.