;;;;;This is here until I figure out how to call gnuplot directly from lisp (defun make-plottable-initial (filename dimensions clusters) (let ((command 0)) (cond ((= dimensions 2) (setf command "plot")) ((= dimensions 3) (setf command "splot"))) (with-open-file (out filename :direction :output :if-exists :supersede) (with-standard-io-syntax (format out "###COLOR BY VALUE###~%# ~a '~a' index 0, '~a' index 1, '~a' index 2~%" command filename filename filename) (format out "###COLOR BY CLUSTER###~%# ~a '~a' index 3" command filename) (dotimes (i (- clusters 1)) (format out ", '~a' index ~a" filename (+ i 4))) (format out "~%###COLOR BY VALUE, LINES BY CLUSTER###~%# ~a '~a' index 0, '~a' index 1,'~a' index 2, '~a' index 3:~a with lines~%" command filename filename filename filename (+ clusters 2)))) 'done)) (defun make-plottable-clusters (matrix filename) "make-plottable-clusters: formats the given sorted data matrix and throws it into the specified file so that is is easily readable by gnuplot. Splits the data into as many classes as in the matrix." (let ((temp (aref matrix 0 (- (array-dimension matrix 1) 1))) (indexcount 4)) (with-open-file (out filename :direction :output :if-exists :append) (with-standard-io-syntax (format out "~%~%###cluster indices###~%###index 3###~%") (dotimes (i (array-dimension matrix 0)) (cond ((/= temp (aref matrix i (- (array-dimension matrix 1) 1))) (setf temp (aref matrix i (- (array-dimension matrix 1) 1))) (format out "~%~%###index ~a###~%" indexcount) (setf indexcount (+ indexcount 1)))) (dotimes (j (- (array-dimension matrix 1) 1)) (format out "~a " (aref matrix i j))) (format out "~%")))) 'done)) ;end make-plottable-clusters (defun make-plottable (matrix filename) "make-plottable: formats the given data matrix and throws it into the specified file so that it is easily readable by gnuplot. Splits the data into three classes: top 10%, middle, bottom 10%" (let ((partition 0)) (setf partition (ceiling (array-dimension matrix 0) 10)) (with-open-file (out filename :direction :output :if-exists :append) (with-standard-io-syntax (format out "###value indices###~%") (format out "###index 0###~%") (dotimes (i partition) (dotimes (j (array-dimension matrix 1)) (format out "~a " (aref matrix i j))) (format out "~%")) (format out "~%~%") (format out "###index 1###~%") (dotimes (i (- (array-dimension matrix 0) partition)) (dotimes (j (array-dimension matrix 1)) (format out "~a " (aref matrix (+ i partition) j))) (format out "~%")) (format out "~%~%") (format out "###index 2###~%") (dotimes (i partition) (dotimes (j (array-dimension matrix 1)) (format out "~a " (aref matrix (+ (- (array-dimension matrix 0) partition) i) j))) (format out "~%")))) 'done)) ;end make-plottable