##********************************************************************** ## plotstack - Copyright (C) 2005 - Cameron Morland ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ##********************************************************************** function x = plotstack(y) ## we're going to generate the gnuplot script tmp = tempname; filename = sprintf("%s.gnuplot", tmp); datafile = sprintf("%s.data", tmp); psfile = sprintf("%s.eps", tmp); out = fopen(filename, "w"); fprintf(out, "set xtics 1\n"); fprintf(out, "set output '/dev/null'\nset term x11\n"); fprintf(out, "set yrange [0:*]\n"); x = [[1:size(y,1)]', zeros(size(y))]; fprintf(out, "plot"); for i = 1:size(y,2) x(:,i+1) = sum(y(:,1:size(y,2)+1-i), 2); fprintf(out, " '%s' usi 1:%d:(0.8) ", datafile, i + 1); fprintf(out, " w boxes fs pattern %d notitle", i); if i < size(y,2) fprintf(out, ",\\"); endif fprintf(out, "\n"); endfor fprintf(out, "set term postscript eps\n"); fprintf(out, "set output '%s'\n", psfile); fprintf(out, "replot\n"); eval(sprintf("save -text '%s' x;", datafile)); fprintf("Now run \n load '%s'\nin gnuplot.\n", filename); fclose(out); endfunction