Mercurial > hg > octave-lyh
annotate scripts/plot/refreshdata.m @ 13141:e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
* bicg.m, gmres.m, pkg.m: Untabify and remove trailing whitespace.
* libcruft/Makefile.am, libcruft/blas-xtra/cdotc3.f,
libcruft/blas-xtra/cmatm3.f, libcruft/blas-xtra/ddot3.f,
libcruft/blas-xtra/dmatm3.f, libcruft/blas-xtra/sdot3.f,
libcruft/blas-xtra/smatm3.f, libcruft/blas-xtra/zdotc3.f,
libcruft/blas-xtra/zmatm3.f, libcruft/lapack-xtra/crsf2csf.f,
libcruft/lapack-xtra/zrsf2csf.f, liboctave/Array.cc,
liboctave/DASPK-opts.in, liboctave/DASRT-opts.in,
liboctave/DASSL-opts.in, liboctave/LSODE-opts.in,
liboctave/Makefile.a,mliboctave/Quad-opts.in,
liboctave/Sparse-perm-op-defs.h,
scripts/Makefile.a,mscripts/deprecated/glpkmex.m,
scripts/general/blkdiag.m, scripts/general/interp1.m,
scripts/general/profshow.m, scripts/general/quadl.m,
scripts/general/triplequad.m, scripts/help/__makeinfo__.m,
scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m,
scripts/linear-algebra/rank.m, scripts/miscellaneous/gzip.m,
scripts/miscellaneous/private/__xzip__.m,
scripts/miscellaneous/tempdir.m, scripts/miscellaneous/unpack.m,
scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m,
scripts/plot/cla.m, scripts/plot/clf.m, scripts/plot/findall.m,
scripts/plot/findobj.m, scripts/plot/gca.m, scripts/plot/gcf.m,
scripts/plot/hggroup.m, scripts/plot/isfigure.m,
scripts/plot/ishghandle.m, scripts/plot/legend.m,
scripts/plot/line.m, scripts/plot/loglog.m, scripts/plot/patch.m,
scripts/plot/print.m, scripts/plot/private/__quiver__.m,
scripts/plot/private/__scatter__.m, scripts/plot/rectangle.m,
scripts/plot/semilogx.m, scripts/plot/semilogy.m,
scripts/plot/surface.m, scripts/plot/text.m, scripts/plot/title.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/whitebg.m,
scripts/plot/xlabel.m, scripts/plot/xlim.m, scripts/plot/ylabel.m,
scripts/plot/ylim.m, scripts/plot/zlabel.m, scripts/plot/zlim.m,
scripts/polynomial/mkpp.m, scripts/polynomial/polygcd.m,
scripts/polynomial/ppint.m, scripts/polynomial/ppjumps.m,
scripts/polynomial/ppval.m, scripts/set/setxor.m,
scripts/sparse/bicgstab.m, scripts/sparse/cgs.m,
scripts/sparse/spconvert.m, scripts/specfun/nthroot.m,
scripts/strings/strmatch.m, scripts/strings/untabify.m,
scripts/testfun/demo.m, scripts/testfun/example.m,
src/DLD-FUNCTIONS/filter.cc, src/DLD-FUNCTIONS/mgorth.cc,
src/DLD-FUNCTIONS/quadcc.cc, src/DLD-FUNCTIONS/str2double.cc,
src/Makefile.a,msrc/gl-render.cc, src/gl2ps-renderer.cc,
src/graphics.cc, src/octave-config.cc.in, src/octave-config.in,
src/ov-class.h, src/ov-fcn.h, src/profiler.cc, src/profiler.h,
src/pt-binop.cc, src/pt-unop.cc, src/symtab.cc, src/txt-eng-ft.cc:
Remove trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Sep 2011 12:51:10 -0400 |
parents | cefd568ea073 |
children | 22c50cbad2ce |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2008-2011 David Bateman |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
2 ## |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
4 ## |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## your option) any later version. |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 ## |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
13 ## General Public License for more details. |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 ## |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
18 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
20 ## @deftypefn {Function File} {} refreshdata () |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 ## @deftypefnx {Function File} {} refreshdata (@var{h}) |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
22 ## @deftypefnx {Function File} {} refreshdata (@var{h}, @var{workspace}) |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
23 ## Evaluate any @samp{datasource} properties of the current figure and update |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
24 ## the plot if the corresponding data has changed. If called with one or more |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
25 ## arguments @var{h} is a scalar or array of figure handles to refresh. The |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
26 ## optional second argument @var{workspace} can take the following values. |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
27 ## |
11595
5ec6aa05638d
Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
28 ## @table @asis |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
29 ## @item "base" |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
30 ## Evaluate the datasource properties in the base workspace. (default). |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
31 ## |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
32 ## @item "caller" |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
33 ## Evaluate the datasource properties in the workspace of the function |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
34 ## that called @code{refreshdata}. |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
35 ## @end table |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
36 ## |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9245
diff
changeset
|
37 ## An example of the use of @code{refreshdata} is: |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 ## |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 ## @example |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
40 ## @group |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
41 ## x = 0:0.1:10; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
42 ## y = sin (x); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
43 ## plot (x, y, "ydatasource", "y"); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
44 ## for i = 1 : 100 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
45 ## pause(0.1) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
46 ## y = sin (x + 0.1 * i); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
47 ## refreshdata(); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
48 ## endfor |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
49 ## @end group |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
50 ## @end example |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
51 ## @end deftypefn |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
52 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
53 function refreshdata (h, workspace) |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
54 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
55 if (nargin == 0) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
56 h = gcf (); |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
57 workspace = "base"; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
58 else |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
59 if (iscell (h)) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
60 h = [h{:}]; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
61 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
62 if (!all (ishandle (h)) || !all (strcmp (get (h, "type"), "figure"))) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
63 error ("refreshdata: expecting a list of figure handles"); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
64 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
65 if (nargin < 2) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
66 workspace = "base"; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
67 else |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
68 if ( !ischar (workspace) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
69 || !(strcmpi (workspace, "base") |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
70 || strcmpi (workspace, "caller"))) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11469
diff
changeset
|
71 error ("refreshdata: expecting WORKSPACE to be \"base\" or ""caller\""); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
72 else |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
73 workspace = tolower (workspace); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
74 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
75 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
76 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
77 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
78 h = findall (h); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
79 objs = []; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
80 props = {}; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
81 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
82 for i = 1 : numel (h) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
83 obj = get (h (i)); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
84 fldnames = fieldnames (obj); |
11032
c9b0a75b02e8
Make all regexp in Octave compatible with both POSIX and PCRE.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
85 m = regexpi (fieldnames(obj), '^.+datasource$', "match"); |
12931
cefd568ea073
Replace function handles with function names in cellfun calls for 15% speedup.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
86 idx = ! cellfun ("isempty", m); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
87 if (any (idx)) |
10439
59967776ed4a
make refreshdata work again
John W. Eaton <jwe@octave.org>
parents:
9316
diff
changeset
|
88 tmp = m(idx); |
59967776ed4a
make refreshdata work again
John W. Eaton <jwe@octave.org>
parents:
9316
diff
changeset
|
89 props = [props; {vertcat(tmp{:})}]; |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
90 objs = [objs ; h(i)]; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
91 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
92 endfor |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
93 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
94 for i = 1 : length (objs) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
95 for j = 1 : length (props {i}) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
96 expr = get (objs(i), props{i}{j}); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
97 if (!isempty (expr)) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11032
diff
changeset
|
98 val = evalin (workspace, expr); |
10549 | 99 prop = props{i}{j}(1:end-6); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
100 if (! isequal (get (objs(i), prop), val)) |
10549 | 101 set (objs(i), props{i}{j}(1:end-6), val); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
102 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
103 endif |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
104 endfor |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
105 endfor |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
106 endfunction |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
107 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
108 %!demo |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
109 %! x = 0:0.1:10; |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
110 %! y = sin (x); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
111 %! plot (x, y, "ydatasource", "y"); |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
112 %! for i = 1 : 100 |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
113 %! pause(0.1) |
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
114 %! y = sin (x + 0.1 * i); |
8260 | 115 %! refreshdata(gcf(), "caller"); |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
116 %! endfor |