3718
|
1 ## Copyright (C) 2000, Teemu Ikonen |
|
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. |
|
23 ## |
|
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 |
|
38 if (nargin < 3) # atleast two data arguments needed |
|
39 usage ("__errplot__ (arg1, ..., fmt)"); |
|
40 endif |
|
41 |
|
42 fstr = " "; |
|
43 ndata = 0; |
3979
|
44 k = 1; |
3718
|
45 |
|
46 while (nargin--) |
3979
|
47 a = varargin{k++}; |
3718
|
48 if (! isstr (a)) |
|
49 ndata++; |
|
50 eval (sprintf ("arg%d = a;", ndata)); |
|
51 else |
|
52 fstr = a; |
|
53 endif |
|
54 endwhile |
|
55 |
|
56 fmt = __pltopt__ ("__errplot__", fstr); |
|
57 |
|
58 nplots = size (arg1, 2); |
|
59 len = size (arg1, 1); |
|
60 |
|
61 if (ndata == 2) |
|
62 for i = 1:nplots, |
|
63 tmp = [(1:len)', arg1(:,i), arg2(:,i)]; |
|
64 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
65 eval (cmd); |
|
66 end |
|
67 elseif (ndata == 3) |
|
68 for i = 1:nplots, |
|
69 tstr = "tmp =[arg1(:,i)"; |
|
70 for j = 2:ndata, |
|
71 tstr = [tstr, sprintf(", arg%d(:,i)", j)]; |
|
72 endfor |
|
73 tstr = [tstr, "];"]; |
|
74 eval (tstr); |
|
75 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
76 eval (cmd); |
|
77 endfor |
|
78 elseif (ndata == 4) |
|
79 for i = 1:nplots, # this is getting ugly |
|
80 if (index (fmt, "boxxy") || index (fmt, "xyerr")) |
|
81 tstr = "tmp = [arg1(:,i), arg2(:,i), arg3(:,i), arg4(:,i)];"; |
|
82 elseif (index (fmt, "xerr")) |
|
83 tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i)];"; |
|
84 else |
|
85 tstr = "tmp = [arg1(:,i), arg2(:,i), arg2(:,i)-arg3(:,i), arg2(:,i)+arg4(:,i)];"; |
|
86 endif |
|
87 eval (tstr); |
|
88 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
89 eval (cmd); |
|
90 endfor |
|
91 elseif (ndata == 6) |
|
92 for i = 1:nplots, |
|
93 tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i), arg2(:,i)-arg5(:,i), arg2(:,i)+arg6(:,i)];"; |
|
94 eval (tstr); |
|
95 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
96 eval (cmd); |
|
97 endfor |
|
98 else |
|
99 for i = 1:nplots, |
|
100 tstr = "tmp = [arg1(:,i)"; |
|
101 for j = 2:ndata, |
|
102 tstr = [tstr, sprintf(", arg%d(:,i)", j)]; |
|
103 endfor |
|
104 tstr = [tstr, "];"]; |
|
105 eval (tstr); |
|
106 cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
107 eval (cmd); |
|
108 endfor |
|
109 endif |
|
110 |
|
111 ## if (ndata == 2) |
|
112 ## for i = 1:nplots, |
|
113 ## tmp = [(1:len)', arg1(:,i), arg2(:,i)]; |
|
114 ## cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
115 ## eval (cmd); |
|
116 ## endfor |
|
117 ## else |
|
118 ## for i = 1:nplots, |
|
119 ## tstr = "tmp =[arg1(:,i)"; |
|
120 ## for j = 2:ndata, |
|
121 ## tstr = [tstr, sprintf(", arg%d(:,i)", j)]; |
|
122 ## endif |
|
123 ## tstr = [tstr, "];"]; |
|
124 ## eval (tstr); |
|
125 ## cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :) ); |
|
126 ## eval (cmd); |
|
127 ## endfor |
|
128 ## endif |
|
129 |
|
130 endfunction |