4007
|
1 ## Copyright (C) 2000, 2001, 2002 Teemu Ikonen |
3718
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __errplot__ (@var{args}) |
|
22 ## Really plot errorbar plots. User interface in function errorbar. |
4007
|
23 ## |
3718
|
24 ## @example |
|
25 ## __errplot__ (@var{arg1}, @var{arg2}, ..., @var{fmt}) |
|
26 ## @end example |
|
27 ## |
|
28 ## @end deftypefn |
|
29 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ |
|
30 ## bar, stairs, errorbar, gplot, gsplot, replot, xlabel, ylabel, and title} |
|
31 |
|
32 ## Created: 18.7.2000 |
|
33 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> |
|
34 ## Keywords: errorbar, plotting |
|
35 |
3979
|
36 function __errplot__ (varargin) |
3718
|
37 |
4717
|
38 nargs = nargin (); |
|
39 |
|
40 if (nargs < 3) # atleast two data arguments needed |
3718
|
41 usage ("__errplot__ (arg1, ..., fmt)"); |
|
42 endif |
|
43 |
|
44 fstr = " "; |
|
45 ndata = 0; |
3979
|
46 k = 1; |
3718
|
47 |
4717
|
48 while (nargs--) |
3979
|
49 a = varargin{k++}; |
3718
|
50 if (! isstr (a)) |
|
51 ndata++; |
|
52 eval (sprintf ("arg%d = a;", ndata)); |
|
53 else |
|
54 fstr = a; |
|
55 endif |
|
56 endwhile |
4007
|
57 |
3718
|
58 fmt = __pltopt__ ("__errplot__", fstr); |
4007
|
59 |
3718
|
60 nplots = size (arg1, 2); |
|
61 len = size (arg1, 1); |
4007
|
62 |
3718
|
63 if (ndata == 2) |
|
64 for i = 1:nplots, |
|
65 tmp = [(1:len)', arg1(:,i), arg2(:,i)]; |
4260
|
66 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :)); |
3718
|
67 eval (cmd); |
4006
|
68 endfor |
3718
|
69 elseif (ndata == 3) |
|
70 for i = 1:nplots, |
|
71 tstr = "tmp =[arg1(:,i)"; |
|
72 for j = 2:ndata, |
4006
|
73 tstr = [tstr, sprintf(", arg%d(:,i)", j)]; |
3718
|
74 endfor |
|
75 tstr = [tstr, "];"]; |
|
76 eval (tstr); |
4260
|
77 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :)); |
3718
|
78 eval (cmd); |
|
79 endfor |
|
80 elseif (ndata == 4) |
|
81 for i = 1:nplots, # this is getting ugly |
|
82 if (index (fmt, "boxxy") || index (fmt, "xyerr")) |
4006
|
83 tstr = "tmp = [arg1(:,i), arg2(:,i), arg3(:,i), arg4(:,i)];"; |
3718
|
84 elseif (index (fmt, "xerr")) |
4006
|
85 tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i)];"; |
3718
|
86 else |
4006
|
87 tstr = "tmp = [arg1(:,i), arg2(:,i), arg2(:,i)-arg3(:,i), arg2(:,i)+arg4(:,i)];"; |
3718
|
88 endif |
|
89 eval (tstr); |
4260
|
90 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :)); |
3718
|
91 eval (cmd); |
|
92 endfor |
|
93 elseif (ndata == 6) |
|
94 for i = 1:nplots, |
|
95 tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i), arg2(:,i)-arg5(:,i), arg2(:,i)+arg6(:,i)];"; |
|
96 eval (tstr); |
4260
|
97 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :)); |
3718
|
98 eval (cmd); |
4007
|
99 endfor |
|
100 else |
3718
|
101 for i = 1:nplots, |
|
102 tstr = "tmp = [arg1(:,i)"; |
|
103 for j = 2:ndata, |
4006
|
104 tstr = [tstr, sprintf(", arg%d(:,i)", j)]; |
3718
|
105 endfor |
|
106 tstr = [tstr, "];"]; |
|
107 eval (tstr); |
4260
|
108 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :)); |
3718
|
109 eval (cmd); |
|
110 endfor |
|
111 endif |
|
112 |
4007
|
113 endfunction |