bugGNU Octave - Bugs: bug #61591, set: inconsistent / incompatible...

 
 

bug #61591: set: inconsistent / incompatible behavior when modifying figure data

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Tue 30 Nov 2021 04:24:30 PM UTC
   
 
Category:  Plotting Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Open
Release:  * 6.4.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 30 Nov 2021 05:21:49 PM UTC, comment #1: 

summarizing:
1 - patch - set does not enforce x/y/zdata as columns like creation does (warning trigger and matlab incompatibility)

2 - patch - set does not trim y/zdata to match when xdata is trimmed (matlab incompatibility), and trimming in multiple steps would produce intermediate warnings.

3 - patch - lets you create a patch with mismatched x/y/zdata, issuing a warning instead of error (matlab incompatibility, but technically allowing a superset of matlab function, so not critical)

4 - patch - replacing mismatched patch from (3) with a matched one doesn't stop the persistent warning.

5 - line - mismatched x/ydata for plot still produces empty figure window.

6 - line/patch - octave behavior appears inversely to match matlab behavior on what works and what produces warnings/errors.

7 - the opengl warning repetition interacts strangely with the interpreter and repeats even after replacing problem causing the warning. (appended this and (4) to bug #61088 about opengl warning repetition)

(all of this on 6.4.0 with windows using qt graphics_toolkit)

Nicholas Jankowski <nrjank>
Group Member
Tue 30 Nov 2021 04:24:30 PM UTC, original submission:  

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.

Nicholas Jankowski <nrjank>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-30 nrjank Releasedev 6.4.0
        Operating SystemAny Microsoft Windows

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code