Mercurial > hg > octave-lyh
annotate scripts/plot/private/__errplot__.m @ 17394:6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
* scripts/help/doc_cache_create.m: Use built-in "isclass" rather than ischar.
Use addpath and rmpath with multiple inputs rather than cellfun.
* scripts/image/imformats.m: Use isfield with cell string list rather
than cellfun.
* scripts/image/private/__imread__.m: Use ismember to replace cellfun/strcmpi
combo.
* scripts/miscellaneous/what.m: Re-order if/elseif tree.
* scripts/pkg/private/rebuild.m: Replace cellfun with strcat call.
* scripts/plot/axis.m: Use comma-separated lists to replace cellfun.
* scripts/plot/pareto.m: Use cellstr on char array to replace cellfun.
* scripts/plot/private/__gnuplot_print__.m: Use @times, rather than
anonymous function, in cellfun call.
* scripts/plot/private/__line__.m: White space cleanup.
* scripts/plot/private/__patch__.m: Use ismember to replace cellfun/strcmpi
combo. Use in-place '|=' operator for performance.
* scripts/plot/struct2hdl.m: Use ismember to replace cellfun/strcmp combo.
* scripts/polynomial/splinefit.m: Use built-in "isclass" rather than ischar.
* scripts/special-matrix/gallery.m: Remove anonymous functions inside cellfuns.
* scripts/strings/strsplit.m: Correct comment character to '#' from '%'.
* scripts/strings/untabify.m: Use multiple argument form of cellfun to get
rid of anonymous function.
* scripts/testfun/__run_test_suite__.m: Remove anonymous function from within
cellfun.
* scripts/ui/inputdlg.m: Use built-in "isclass" rather than ischar.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 06 Sep 2013 14:08:42 -0700 |
parents | 088d014a7fe2 |
children | 4a6a4657fdf2 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13221
diff
changeset
|
1 ## Copyright (C) 2000-2012 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
3718 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
3718 | 18 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
19 ## -*- texinfo -*- |
17184
abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents:
17129
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} __errplot__ (@var{fstr}, @var{hax}, @dots{}) |
6895 | 21 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
22 ## @end deftypefn |
5720 | 23 |
3718 | 24 ## Created: 18.7.2000 |
25 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> | |
26 ## Keywords: errorbar, plotting | |
27 | |
17184
abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents:
17129
diff
changeset
|
28 function h = __errplot__ (fstr, hax, varargin) |
4007 | 29 |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
30 [fmt, valid] = __pltopt__ ("__errplot__", fstr); |
6146 | 31 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
32 [len, nplots] = size (varargin{1}); |
8258 | 33 h = []; |
4007 | 34 |
4897 | 35 for i = 1:nplots |
6736 | 36 ## Set the plot type based on linestyle. |
8258 | 37 |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
38 if (strcmp (fmt.errorstyle, "~")) |
6736 | 39 ifmt = "yerr"; |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
40 elseif (strcmp (fmt.errorstyle, ">")) |
6736 | 41 ifmt = "xerr"; |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
42 elseif (strcmp (fmt.errorstyle, "~>")) |
6736 | 43 ifmt = "xyerr"; |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
44 elseif (strcmp (fmt.errorstyle, "#")) |
6736 | 45 ifmt = "box"; |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
46 elseif (strcmp (fmt.errorstyle, "#~")) |
6736 | 47 ifmt = "boxy"; |
10590
083e4f6143fe
__errplot__.m: Fix bug for boxxy errorbar.
Ben Abbott <bpabbott@mac.com>
parents:
10587
diff
changeset
|
48 elseif (strcmp (fmt.errorstyle, "#~>")) |
6736 | 49 ifmt = "boxxy"; |
50 else | |
11099
65b240770880
Fix normal line and marker types for errorplots.
Ben Abbott <bpabbott@mac.com>
parents:
10635
diff
changeset
|
51 ifmt = "yerr"; |
10576
384c514bbae2
Allow setting of the markers in errorbar linestyles
David Bateman <dbateman@free.fr>
parents:
10575
diff
changeset
|
52 endif |
384c514bbae2
Allow setting of the markers in errorbar linestyles
David Bateman <dbateman@free.fr>
parents:
10575
diff
changeset
|
53 |
17184
abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
Rik <rik@octave.org>
parents:
17129
diff
changeset
|
54 hg = hggroup ("parent", hax); |
8258 | 55 h = [h; hg]; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 args = __add_datasource__ ("__errplot__", hg, |
10549 | 57 {"x", "y", "l", "u", "xl", "xu"}); |
8258 | 58 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
59 if (isempty (fmt.color)) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
60 fmt.color = __next_line_color__ (); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
61 endif |
10580
1479b93ee655
Respect linestyleorder in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10576
diff
changeset
|
62 if (isempty (fmt.marker) && isempty (fmt.linestyle)) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
63 [fmt.linestyle, fmt.marker] = __next_line_style__ (); |
10575
3eba2cc7cbda
Allow matlab style linestyles in errorbar plots
David Bateman <dbateman@free.fr>
parents:
10573
diff
changeset
|
64 endif |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
65 hl = [(__line__ (hg, "linestyle", fmt.linestyle, "marker", fmt.marker, |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
66 "color", fmt.color)), |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
67 (__line__ (hg, "linestyle", "-", "marker", "none", |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
68 "color", fmt.color))]; |
6736 | 69 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
70 switch (numel (varargin)) |
4897 | 71 case 2 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
72 ydata = varargin{1}(:,i); |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
73 xdata = 1:numel (ydata); |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
74 if (strcmp (ifmt, "xerr") || strcmp (ifmt, "box")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
75 xldata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
76 xudata = ldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
77 ldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
78 udata = []; |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
79 elseif (strcmp (ifmt, "yerr") || strcmp (ifmt, "boxy")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
80 ldata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
81 udata = ldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
82 xldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
83 xudata = []; |
10573
d8894a2d0a03
Allow x, xy and box errorbars with different plotting syntax
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
84 else |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
85 error ("errorbar: 2 column errorplot is only valid for xerr or yerr"); |
10573
d8894a2d0a03
Allow x, xy and box errorbars with different plotting syntax
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
86 endif |
4897 | 87 case 3 |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
88 if (strcmp (ifmt, "boxxy") || strcmp (ifmt, "xyerr")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
89 ydata = varargin{1}(:,i); |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
90 xdata = 1:numel (ydata); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
91 xldata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
92 xudata = xldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
93 ldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
94 udata = ldata; |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
95 elseif (strcmp (ifmt, "xerr") || strcmp (ifmt, "box")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
96 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
97 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
98 xldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
99 xudata = xldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
100 ldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
101 udata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
102 else # yerr or boxy |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
103 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
104 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
105 ldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
106 udata = ldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
107 xldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
108 xudata = []; |
10573
d8894a2d0a03
Allow x, xy and box errorbars with different plotting syntax
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
109 endif |
4897 | 110 case 4 |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
111 if (strcmp (ifmt, "boxxy") || strcmp (ifmt, "xyerr")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
112 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
113 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
114 xldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
115 xudata = xldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
116 ldata = varargin{4}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
117 udata = ldata; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
118 elseif (strcmp (ifmt, "xerr") || strcmp (ifmt, "box")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
119 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
120 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
121 xldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
122 xudata = varargin{4}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
123 ldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
124 udata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
125 else # yerr or boxy |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
126 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
127 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
128 ldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
129 udata = varargin{4}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
130 xldata = []; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
131 xudata = []; |
10549 | 132 endif |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
133 case 6 # boxxy, xyerr |
10594
4b421123fd17
__errplot__.m: Fix bug parsing errorbar style.
Ben Abbott <bpabbott@mac.com>
parents:
10592
diff
changeset
|
134 if (strcmp (ifmt, "boxxy") || strcmp (ifmt, "xyerr")) |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
135 xdata = varargin{1}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
136 ydata = varargin{2}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
137 xldata = varargin{3}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
138 xudata = varargin{4}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
139 ldata = varargin{5}(:,i); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
140 udata = varargin{6}(:,i); |
10573
d8894a2d0a03
Allow x, xy and box errorbars with different plotting syntax
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
141 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10594
diff
changeset
|
142 error ("errorbar: error plot with 6 columns only valid for boxxy and xyerr"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
143 endif |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
144 otherwise |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
145 error ("errorbar: error plot requires 2, 3, 4, or 6 arguments"); |
4897 | 146 endswitch |
8258 | 147 |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
148 addproperty ("xdata", hg, "data", xdata(:)); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
149 addproperty ("ydata", hg, "data", ydata(:)); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
150 addproperty ("ldata", hg, "data", ldata(:)); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
151 addproperty ("udata", hg, "data", udata(:)); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
152 addproperty ("xldata", hg, "data", xldata(:)); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
153 addproperty ("xudata", hg, "data", xudata(:)); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
154 addproperty ("format", hg, "string", ifmt); |
10587
eb69d94e8648
Update the errorbar markers in a seperate listtener function
David Bateman <dbateman@free.fr>
parents:
10584
diff
changeset
|
155 |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
156 addproperty ("color", hg, "linecolor", get (hl(1), "color")); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
157 addproperty ("linewidth", hg, "linelinewidth", get (hl(1), "linewidth")); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
158 addproperty ("linestyle", hg, "linelinestyle", get (hl(1), "linestyle")); |
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
159 addproperty ("marker", hg, "linemarker", get (hl(1), "marker")); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
160 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
161 get (hl(1), "markerfacecolor")); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
162 addproperty ("markeredgecolor", hg, "linemarkerfacecolor", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
163 get (hl(1), "markeredgecolor")); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
164 addproperty ("markersize", hg, "linemarkersize", |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
165 get (hl(1), "markersize")); |
8258 | 166 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
167 fcn = {@update_props, hl}; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
168 addlistener (hg, "color", fcn); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
169 addlistener (hg, "linewidth", fcn); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
170 addlistener (hg, "linestyle", fcn); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
171 addlistener (hg, "marker", fcn); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
172 addlistener (hg, "markerfacecolor", fcn); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
173 addlistener (hg, "markersize", fcn); |
8258 | 174 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
175 fcn = {@update_data, hl}; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
176 addlistener (hg, "xdata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
177 addlistener (hg, "ydata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
178 addlistener (hg, "ldata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
179 addlistener (hg, "udata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
180 addlistener (hg, "xldata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
181 addlistener (hg, "xudata", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
182 addlistener (hg, "format", fcn); |
8258 | 183 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
184 hax = ancestor (hg, "axes"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
185 addlistener (hax, "xscale", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
186 addlistener (hax, "yscale", fcn); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
187 |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
188 update_data (hg, [], hl); |
8258 | 189 |
5406 | 190 endfor |
191 | |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
192 ## Process legend key |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
193 if (! isempty (fmt.key)) |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
194 hlegend = []; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
195 fkids = get (gcf (), "children"); |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
196 for i = 1 : numel (fkids) |
17129
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
197 if ( strcmp (get (fkids(i), "type"), "axes") |
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
198 && strcmp (get (fkids(i), "tag"), "legend")) |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
199 udata = get (fkids(i), "userdata"); |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
200 if (! isempty (intersect (udata.handle, gca ()))) |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
201 hlegend = fkids (i); |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
202 break; |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
203 endif |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
204 endif |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
205 endfor |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
206 |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
207 if (isempty (hlegend)) |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
208 hlgnd = []; |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
209 tlgnd = {}; |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
210 else |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
211 [hlgnd, tlgnd] = __getlegenddata__ (hlegend); |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
212 endif |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
213 |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
214 hlgnd(end+1) = hg; |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
215 tlgnd(end+1) = fmt.key; |
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
216 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
217 legend (gca (), hlgnd, tlgnd); |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
218 endif |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
219 |
4007 | 220 endfunction |
8258 | 221 |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
222 function [xdata, ydata] = errorbar_data (xdata, ydata, ldata, udata, |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
223 xldata, xudata, ifmt, |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
224 xscale, yscale) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
225 if (strcmp (xscale, "linear")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
226 dx = 0.01 * (max (xdata(:)) - min (xdata(:))); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
227 xlo = xdata - dx; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
228 xhi = xdata + dx; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
229 else |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
230 n = xdata > 0; |
17312
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
231 if (! any (n)) |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
232 n = xdata < 0; |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
233 endif |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
234 logdata = log (abs (xdata(n))); |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
235 rx = exp (0.01 * (max (logdata) - min (logdata))); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
236 xlo = xdata/rx; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
237 xhi = xdata*rx; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
238 endif |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
239 if (strcmp (yscale, "linear")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
240 dy = 0.01 * (max (ydata(:)) - min (ydata(:))); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
241 ylo = ydata - dy; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
242 yhi = ydata + dy; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
243 else |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
244 n = ydata > 0; |
17312
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
245 if (! any (n)) |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
246 n = ydata < 0; |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
247 endif |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
248 logdata = log (abs (ydata(n))); |
4c7ee36f591d
__errplot__.m: Fix bug with loglogerr and negative y values (bug #39837).
Rik <rik@octave.org>
parents:
17184
diff
changeset
|
249 ry = exp (0.01 * (max (logdata) - min (logdata))); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
250 ylo = ydata/ry; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
251 yhi = ydata*ry; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
252 endif |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
253 nans = NaN + xdata(:); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
254 if (strcmp (ifmt, "yerr")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
255 xdata = [xdata, xdata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
256 xlo, xhi, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
257 xlo, xhi, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
258 ydata = [ydata-ldata, ydata+udata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
259 ydata+udata, ydata+udata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
260 ydata-ldata, ydata-ldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
261 elseif (strcmp (ifmt, "xerr")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
262 xdata = [xdata-xldata, xdata+xudata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
263 xdata+xudata, xdata+xudata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
264 xdata-xldata, xdata-xldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
265 ydata = [ydata, ydata, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
266 ylo, yhi, nans, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
267 ylo, yhi, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
268 elseif (strcmp (ifmt, "boxy")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
269 dx = 0.01 * (max (xdata(:)) - min (xdata(:))); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
270 xdata = [xlo, xhi, xhi, xlo, xlo, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
271 ydata = [ydata-ldata, ydata-ldata, ydata+udata, ydata+udata, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
272 ydata-ldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
273 elseif (strcmp (ifmt, "box")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
274 dy = 0.01 * (max (ydata(:)) - min (ydata(:))); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
275 xdata = [xdata-xldata, xdata+xudata, xdata+xudata, xdata-xldata, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
276 xdata-xldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
277 ydata = [ylo, ylo, yhi, yhi, ylo, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
278 elseif (strcmp (ifmt, "boxxy")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
279 xdata = [xdata-xldata, xdata+xudata, xdata+xudata, xdata-xldata, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
280 xdata-xldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
281 ydata = [ydata-ldata, ydata-ldata, ydata+udata, ydata+udata, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
282 ydata-ldata, nans]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
283 elseif (strcmp (ifmt, "xyerr")) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
284 [x1, y1] = errorbar_data (xdata, ydata, ldata, udata, |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
285 xldata, xudata, "xerr", xscale, yscale); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
286 [x2, y2] = errorbar_data (xdata, ydata, ldata, udata, |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
287 xldata, xudata, "yerr", xscale, yscale); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
288 xdata = [x1; x2]; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
289 ydata = [y1; y2]; |
17320
088d014a7fe2
Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents:
17312
diff
changeset
|
290 return; |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
291 else |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
292 error ("errorbar: valid error bar types are xerr, yerr, boxxy, and xyerr"); |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
293 endif |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
294 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
295 xdata = xdata.'(:); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
296 ydata = ydata.'(:); |
13221
cc6e9425c04e
errorbar plots can now accept a legend key (Bug #33580).
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
297 |
8258 | 298 endfunction |
299 | |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
300 function update_props (hg, dummy, hl) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
301 set (hl, "color", get (hg, "color"), |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
302 "linewidth", get (hg, "linewidth"));, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
303 set (hl(1), "linestyle", get (hg, "linestyle"), |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
304 "marker", get (hg, "marker"), |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
305 "markersize", get (hg, "markersize"), |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
306 "markerfacecolor", get (hg, "markerfacecolor"), |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
307 "markeredgecolor", get (hg, "markeredgecolor")); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
308 endfunction |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
309 |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
310 function update_data (hg, dummy, hl) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
311 |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
312 if (strcmp (get (hg, "type"), "axes")) |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
313 hax = hg; |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
314 hg = ancestor (hl(1), "hggroup"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
315 else |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
316 hax = ancestor (hg, "axes"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
317 endif |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
318 xscale = get (hax, "xscale"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
319 yscale = get (hax, "yscale"); |
8258 | 320 |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
321 xdata = get (hg, "xdata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
322 ydata = get (hg, "ydata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
323 ldata = get (hg, "ldata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
324 udata = get (hg, "udata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
325 xldata = get (hg, "xldata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
326 xudata = get (hg, "xudata"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
327 ifmt = get (hg, "format"); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
328 |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
329 set (hl(1), "xdata", xdata); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
330 set (hl(1), "ydata", ydata); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
331 |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
332 [errorbar_xdata, errorbar_ydata] = ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
333 errorbar_data (xdata, ydata, ldata, udata, xldata, xudata, ... |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
334 ifmt, xscale, yscale); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
335 |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
336 set (hl(2), "xdata", errorbar_xdata); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
337 set (hl(2), "ydata", errorbar_ydata); |
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
338 |
8258 | 339 endfunction |
10592
f0a7a72c1fbf
__errplot__.m: Implement errorbars in the Matlab style.
Ben Abbott <bpabbott@mac.com>
parents:
10590
diff
changeset
|
340 |