[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61591] set: inconsistent / incompatible behav
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #61591] set: inconsistent / incompatible behavior when modifying figure data |
Date: |
Tue, 30 Nov 2021 11:24:32 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?61591>
Summary: set: inconsistent / incompatible behavior when
modifying figure data
Project: GNU Octave
Submitted by: nrjank
Submitted on: Tue 30 Nov 2021 11:24:30 AM EST
Category: Plotting
Severity: 2 - Minor
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: Confirmed
Assigned to: None
Originator Name: Nicholas Jankowski
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
splitting this off of bug #39243
When plotting multi-dimensional data, most require equal length data elements
(numel(xdata)=numel(ydata)=numel(zdata)...), and this requirement is
consistent between octave and matlab. The behavior when using the set command
in modifying that data is inconsistent (some on both sides).
first noticed this with 'patch' in the bug report mentioned above:
Matlab 2021a:
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = patch (xdata(1:end-1), ydata, 'b', 'marker', 's'); %% expected error
Error using patch
Vectors must be the same length.
h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon
get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
set (h, 'xdata', xdata(1:end-3)); %%plot updates removing 2 points from hex
get(h,'xdata'), get(h, 'ydata') %% set also trimmed y data to match x
ans =
1.0000
0.5000
-0.5000
-1.0000
ans =
0
0.8660
0.8660
0
set (h, 'ydata', ydata(1:end-4)); %%plot updates removing another point
get(h,'xdata'), get(h, 'ydata') %% set also trimmed x data to match y
ans =
1.0000
0.5000
-0.5000
ans =
0
0.8660
0.8660
Octave produces warnings and clears the plot when set produces a mismatch:
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = patch (xdata(1:end-1), ydata, 'b', 'marker', 's'); %% warning instead of
error.
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
***warning repeats in console window on any figure interaction, displaces next
>> prompt ***
get(h, 'xdata'), get(h, 'ydata') %% octave lets you create the figure, just
not render it
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon, but with more
warnings
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
get(h, 'xdata'), get(h, 'ydata') %% octave lets you create the figure, just
not render it
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
*** despite redefining h, any figure interaction (clicking) keeps produces
warnings in console ***
refreshing to clear earlier persistent warning:
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = patch (xdata, ydata, 'b', 'marker', 's'); %%draws hexagon
set (h, 'xdata', xdata(1:end-3)); %hexagon disappears
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
set (h, 'ydata', ydata(1:end-3)); %%shape reappears as 4pt figure
get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0
Also noticed the row/column vector orientation change, and Octave throws the
same warning error if numel is the same but shape is not (matlab always keeps
the data as column vectors, so
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = patch (xdata, ydata', 'b', 'marker', 's'); %hex renders as expected
get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
set (h, 'ydata', ydata(1:end)); %%figure disappears
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
repeating the test above with a line plot, the behavior changes:
Matlab:
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = plot(xdata(1:end-3),ydata); %%error, no figure window created
Error using plot
Vectors must be the same length.
h = plot(xdata,ydata);
get(h, 'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
set(h, 'xdata', xdata')
get(h, 'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
set(h, 'xdata', xdata(1:end-3))
Warning: Error creating or updating Line
Error in value of one or more of the following properties:
XData YData
Array is wrong shape or size
get(h, 'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
set(h, 'ydata', ydata(1:end-3))
get(h, 'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0
so matlab plots behave like octave for patches, except matlab enforces rows
instead of columns.
now looking at octave for line plots:
xdata = cosd (0:60:360);
ydata = sind (0:60:360);
h = plot(xdata(1:end-3),ydata); %%error, empty figure window created
error: __plt2vv__: vector lengths must match
error: called from
__plt__>__plt2vv__ at line 487 column 5
__plt__>__plt2__ at line 247 column 14
__plt__ at line 112 column 18
plot at line 229 column 10
>> get(h,'xdata'), get(h, 'ydata') %% verified no h created
error: 'h' undefined near line 1, column 1
>> h = plot(xdata,ydata);
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
>> set (h, 'xdata', xdata'); %%octave preserves row vector
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
>> set (h, 'xdata', xdata(1:end-3)); %%figure redraws with 4pts, but ylim
based on full y range
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0 -0.8660 -0.8660 0
>> set (h, 'ydata', ydata(1:end-3));
>> set (h, 'ydata', ydata);
>> set (h, 'ydata', ydata(1:end-3));
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0
that's quite a mess, so I'll try to summarize in comment #1.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61591>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61591] set: inconsistent / incompatible behavior when modifying figure data,
Nicholas Jankowski <=