Issue with hggroup and zlim
John W. Eaton
jwe at bevo.che.wisc.edu
Thu Aug 28 12:23:07 CDT 2008
On 28-Aug-2008, David Bateman wrote:
| John W. Eaton wrote:
| > I'm seeing this odd behavior after starting a fresh Octave session:
| >
| >
| <snip>
| > I don't understand how HG has magically been converted from an hggroup
| > object to a text object.
| >
| >
|
| Errr, no ideas though I don't think I changed anything that might do
| this. Perhaps run octave through valgrind and test again and see if
| there are any writes over the end an an array.
OK, I rebuilt from scratch and now I hit this problem:
octave:2> h = plot3 (z, exp(2i*pi*z),'parent',hg);
Invalid call to print_usage. Correct usage is:
-- Loadable Function: print_usage ()
Additional help for built-in functions and operators is
available in the on-line version of the manual. Use the command
`doc <topic>' to search the manual index.
Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help at octave.org
mailing list.
error: called from:
error: /home/jwe/src/octave/scripts/plot/__line__.m at line 51, column 5
error: /home/jwe/src/octave/scripts/plot/line.m at line 41, column 5
error: /home/jwe/src/octave/scripts/plot/plot3.m at line 305, column 11
This error happens at this point in __line__.m:
if (rem (nvargs - num_data_args, 2) == 0)
else
print_usage ("line");
endif
First, there's clearly a problem since we expect to be able to call
print_usage with a function name and that no longer works. I'm not
sure of the best fix here, but since this is an internal function, I
don't think it matters much as we should probably never call it
incorrectly. So I'd probably say we should change the above to
if (rem (nvargs - num_data_args, 2) != 0)
print_usage ();
endif
But, why don't we have an even number of arguments?
The last elements of varargin at this point are:
[1,12] = parent
[1,13] = -2.6959
[1,14] = parent
so somehow the parent property tag is being added twice, and the
second time without the corresponding value. Looking at the way
line is called at line 305 of plot3.m, I see
properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
"linestyle", options.linestyle,
"marker", options.marker, "parent", hg, properties{:});
__add_line_series__ (h, hg);
Before the call to __add_datasource__, properties has the value:
properties =
{
[1,1] = parent
[1,2] = -2.6959
}
After the call, it is:
properties =
{
[1,1] = parent
}
Looking at __add_datasource__.m, I see
i = 1;
newargs = {};
while (i < numel (varargin))
arg = varargin{i++};
if (ischar (arg) && length (arg > 1) && strcmpi (arg(2:end), "datasource"))
arg = tolower (arg);
val = varargin{i++};
if (ischar (val))
set (h, arg, val);
else
error ("%s: expecting data source to be a string", fcn);
endif
else
newargs{end + 1} = arg;
endif
endwhile
Should the test in this loop be <= instead of < ? If so, then newargs
will contain the parent argument and the calls to __line__ in plot3
will need to be modified. For example, I would propose this change:
diff --git a/scripts/plot/__add_datasource__.m b/scripts/plot/__add_datasource__.m
--- a/scripts/plot/__add_datasource__.m
+++ b/scripts/plot/__add_datasource__.m
@@ -34,7 +34,7 @@
i = 1;
newargs = {};
- while (i < numel (varargin))
+ while (i <= numel (varargin))
arg = varargin{i++};
if (ischar (arg) && length (arg > 1) && strcmpi (arg(2:end), "datasource"))
arg = tolower (arg);
diff --git a/scripts/plot/plot3.m b/scripts/plot/plot3.m
--- a/scripts/plot/plot3.m
+++ b/scripts/plot/plot3.m
@@ -231,7 +231,7 @@
hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
"linestyle", options.linestyle,
- "marker", options.marker, "parent", hg, properties{:});
+ "marker", options.marker, properties{:});
__add_line_series__ (h, hg);
@@ -301,7 +301,7 @@
hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
"linestyle", options.linestyle,
- "marker", options.marker, "parent", hg, properties{:});
+ "marker", options.marker, properties{:});
__add_line_series__ (h, hg);
endif
Or is there some other fix that is better?
Finally, if I make this change, I see the following error:
octave:1> z = [0:0.05:5]; hold on; hg = hggroup();
octave:2> h = plot3 (z, exp(2i*pi*z),'parent',hg);
error: `h' undefined near line 309 column 26
error: evaluating argument list element number 1
error: called from:
error: /home/jwe/src/octave/scripts/plot/plot3.m at line 309, column 5
This is happening at the line
__add_line_series__ (h, hg);
Should that be hline instead of h? There are two cases like this in
plot3. I'm not sure of the intent here.
If I make that change, then I see
octave:1> z = [0:0.05:5]; hold on; hg = hggroup();
octave:2> h = plot3 (z, exp(2i*pi*z),'parent',hg);
octave:3> h = plot3 (z, exp(2i*pi*z),'parent',hg);
error: __go_line__: invalid parent
error: called from:
error: /home/jwe/src/octave/scripts/plot/__line__.m at line 67, column 5
error: /home/jwe/src/octave/scripts/plot/line.m at line 41, column 5
error: /home/jwe/src/octave/scripts/plot/plot3.m at line 305, column 11
so the first call works, but the second fails. I'm lost at this point.
jwe
More information about the Bug-octave
mailing list