anchor.diff:  				    :input :stream))
         *gnuplot-process*))
   
  -(defun parse-style (style-alist)
  -  (with-output-to-string (s)
  -    ;; Do we have a title?  Print it first
  -    (when (assoc :title style-alist)
  -      (format s " title ~S" (cadr (assoc :title style-alist)))
  -      (setf style-alist (remove-if (lambda (k) (eq (car k) :title)) style-alist)))
  +(defun parse-style (stream style-number args)
  +  ;; Do we have a title?  Print it first
   
  -    ;; More style directives?  They live together
  -    (when style-alist
  -      (format s " with ")
  -      (loop for (key value) in style-alist
  -	 do (cond
  -	      ((eq key :line-style)
  -	       (format s "~a" (cond
  -			      ((eq value :line) "line")
  -			      ((eq value :line-points) "linespoints"))))
  -	      ((eq key :yerr)
  -	       (format s " yerr ")))))))
  +  (format stream "set style line ~d " style-number)
  +  ;; More style directives?  They live together
  +
  +  (if args
  +      (destructuring-bind (&key line-type line-color line-width point-type point-size &allow-other-keys) args
  +	(when line-type (format stream "lt ~a " line-type))
  +	(when line-color (format stream "lc ~a " line-color))
  +	(when line-width (format stream "lw ~a " line-width))
  +	(when point-type (format stream "pt ~a " point-type))
  +	(when point-size (format stream "ps ~a " point-size))
  +	(format stream "~%"))
  +      (format stream "default~%")))
   
   (defun print-vectors-to-stream (stream x y)
   	  (loop for xi across x
  
positive.code:        do (format s "~%"))
      (format s "e~%")))
  
  (defun plot3d (data)
  ;  (declare (type real-matrix data))
    (with-plot s
  ;    (format s "set pm3d~%")
      (format s "set isosample 4~%")
      (format s "splot '-'~%")
      (loop for i from 0 upto (1- (array-dimension data 0))
  	 do (loop for j from 0 upto (1- (array-dimension data 1))
  		 do (format s "~g " (aref data i j)))
  	 do (format s "~%"))
      (format s "e~%")))
  
negative.code: 	     do (format stream "~1,8f ~1,8f~%" xi yi))
  	  (format stream "e~%"))
  
  (defun plot (plot-sexps &key title (terminal :wxt) (pathspec "") x-label y-label)
    ;; Make sure args is always a list of plot specs
    (let ((plot-sexps (if (consp (car plot-sexps))
  			plot-sexps
  			(list plot-sexps))))
  
      (with-plot (stream terminal pathspec)
         (when title (format stream "set title ~S~%" title))
         (when x-label (format stream "set xlabel ~S~%" x-label))
         (when y-label (format stream "set ylabel ~S~%" y-label))
  
        ;; Write line styles to stream
        (loop
  	 for plot in plot-sexps
  	 for number from 1 by 1
  	 do (parse-style stream number (subseq plot 2)))
  
        ;; Write plot commands to stream
        (loop
  	 for plot in plot-sexps
  	 for number from 1 by 1
  	 initially (princ "plot " stream)
  	 do (format stream
  		    "'-' using 1:2 ls ~d title ~S with ~a"
  		    number
  		    (or (getf plot :title) "")
  		    (or (case (getf plot :line-style)
  			  (:lines "lines")
  			  (:points "points")
  			  (:lines-points "linespoints")
  			  (:impulses "impulses")
  			  (:dots "dots")
  			  (:steps "steps")
  			  ;; FIXME: Add others once we can parse more vectors (errorbars)
  			  (t "lines"))))
  	 unless (= (length plot-sexps) number)
  	 do (princ ", " stream)
  	 finally (princ #\Newline stream))
  
        
        (loop
  	 for plot in plot-sexps
  	 do (destructuring-bind (x y) (subseq plot 0 2)
  	      ;; hah! second-class functions to the rescue!
  	      (print-vectors-to-stream stream x y))))))
  
  (defun image (data &key title (terminal :wxt) (pathspec "") x-label y-label)
    (with-plot (s terminal pathspec)
      (when title (format s "set title ~S~%" title))
      (when x-label (format s "set xlabel ~S~%" x-label))
      (when y-label (format s "set ylabel ~S~%" y-label))
  
      (format s "set pm3d map~%")
      (format s "set size ratio 1~%")
      (format s "splot '-' matrix~%")
      (loop for i from (1- (array-dimension data 1)) downto 0
         do (loop for j from 0 upto (1- (array-dimension data 0))
  