Back to index

texmacs  1.0.7.15
__errplot__.m
Go to the documentation of this file.
00001 ## Copyright (C) 2000, Teemu Ikonen
00002 ##
00003 ## This file is part of Octave.
00004 ##
00005 ## Octave is free software; you can redistribute it and/or modify it
00006 ## under the terms of the GNU General Public License as published by
00007 ## the Free Software Foundation; either version 2, or (at your option)
00008 ## any later version.
00009 ##
00010 ## Octave is distributed in the hope that it will be useful, but
00011 ## WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 ## General Public License for more details.
00014 ##
00015 ## You should have received a copy of the GNU General Public License
00016 ## along with Octave; see the file COPYING.  If not, write to the Free
00017 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
00018 ## 02111-1307, USA.
00019 
00020 ## -*- texinfo -*-
00021 ## @deftypefn {Function File} {} __errplot__ (@var{args})
00022 ## Really plot errorbar plots. User interface in function errorbar.
00023 ##
00024 ## @example
00025 ## __errplot__ (@var{arg1}, @var{arg2}, ..., @var{fmt})
00026 ## @end example
00027 ##
00028 ## @end deftypefn
00029 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__
00030 ## bar, stairs, errorbar, gplot, gsplot, replot, xlabel, ylabel, and title}
00031 
00032 ## Created: 18.7.2000
00033 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
00034 ## Keywords: errorbar, plotting
00035 
00036 ## Modified Feb. 2003 -- Added TeXmacs interface support
00037 ## Author: Michael Graffam <mgraffam@mathlab.sunysb.edu>
00038 
00039 function __errplot__ (...)
00040 
00041   if (nargin < 3) # atleast two data arguments needed
00042     usage ("__errplot__ (arg1, ..., fmt)");
00043   endif
00044  
00045   fstr = " ";
00046 
00047   ndata = 0;
00048 
00049   if (length(getenv("TEXMACS_PATH"))>0)
00050        gset output '/tmp/tmplot.eps';
00051   endif
00052 
00053   while (nargin--)
00054     a = va_arg ();
00055     if (! isstr (a))
00056       ndata++;
00057       eval (sprintf ("arg%d = a;", ndata));
00058     else
00059       fstr = a;
00060     endif
00061   endwhile
00062 
00063   fmt = __pltopt__ ("__errplot__", fstr);
00064 
00065   nplots = size (arg1, 2);
00066   len = size (arg1, 1);
00067 
00068   if (ndata == 2)
00069     for i = 1:nplots,
00070       tmp = [(1:len)', arg1(:,i), arg2(:,i)];
00071       cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00072       eval (cmd);
00073     end
00074   elseif (ndata == 3)
00075     for i = 1:nplots,
00076       tstr = "tmp =[arg1(:,i)";
00077       for j = 2:ndata,
00078        tstr = [tstr, sprintf(", arg%d(:,i)", j)];
00079       endfor
00080       tstr = [tstr, "];"];
00081       eval (tstr);
00082       cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00083       eval (cmd);
00084     endfor
00085   elseif (ndata == 4)
00086     for i = 1:nplots, # this is getting ugly
00087       if (index (fmt, "boxxy") || index (fmt, "xyerr"))
00088        tstr = "tmp = [arg1(:,i), arg2(:,i), arg3(:,i), arg4(:,i)];";
00089       elseif (index (fmt, "xerr"))
00090        tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i)];";
00091       else
00092        tstr = "tmp = [arg1(:,i), arg2(:,i), arg2(:,i)-arg3(:,i), arg2(:,i)+arg4(:,i)];";
00093       endif
00094       eval (tstr);
00095       cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00096       eval (cmd);
00097     endfor
00098   elseif (ndata == 6)
00099     for i = 1:nplots,
00100       tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i), arg2(:,i)-arg5(:,i), arg2(:,i)+arg6(:,i)];";
00101       eval (tstr);
00102       cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00103       eval (cmd);
00104     endfor
00105   else
00106     for i = 1:nplots,
00107       tstr = "tmp = [arg1(:,i)";
00108       for j = 2:ndata,
00109        tstr = [tstr, sprintf(", arg%d(:,i)", j)];
00110       endfor
00111       tstr = [tstr, "];"];
00112       eval (tstr);
00113       cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00114       eval (cmd);
00115     endfor
00116   endif
00117 
00118           if (length(getenv("TEXMACS_PATH"))>0)
00119                P=[2;112;115;58]; #P= "\002ps:"
00120                 g=fopen("/tmp/tmplot.eps");
00121                 while (g==-1)
00122                         sleep(1);
00123                         g=fopen("/tmp/tmplot.eps");
00124                 endwhile
00125                 while (!feof(g))
00126                         f=fread(g,2048);
00127                         if (length(f))
00128                                 P=[P;f];
00129                         endif
00130                 endwhile
00131                 fclose(g);
00132                 P=[P;5];
00133                 disp(sprintf("%cverbatim:\n",2));
00134                 disp(setstr(P'));
00135                 system("rm /tmp/tmplot.eps");
00136         endif
00137 
00138   ## if (ndata == 2)
00139   ##   for i = 1:nplots,
00140   ##     tmp = [(1:len)', arg1(:,i), arg2(:,i)];
00141   ##     cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00142   ##     eval (cmd);
00143   ##   endfor
00144   ## else
00145   ##   for i = 1:nplots,
00146   ##     tstr = "tmp =[arg1(:,i)";
00147   ##     for j = 2:ndata,
00148   ##       tstr = [tstr, sprintf(", arg%d(:,i)", j)];
00149   ##     endif
00150   ##     tstr = [tstr, "];"];
00151   ##     eval (tstr);
00152   ##     cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) );
00153   ##     eval (cmd);
00154   ##   endfor
00155   ## endif
00156 
00157 endfunction