bugGNU Octave - Bugs: bug #53215, plot3 with empty arguments does...

 
 

bug #53215: plot3 with empty arguments does not set the return plot handle

Submitter:  Marshall <marsian>
Submitted:  Sat 24 Feb 2018 02:09:33 AM UTC
   
 
Category:  Plotting Severity:  1 - Wish
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Marsian Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 02 Mar 2018 04:38:19 AM UTC, comment #3: 

I changed plot3 to return an empty matrix, as plot does, when there is no input data.  See this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/d55e100aebc9).

Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Fri 02 Mar 2018 04:20:33 AM UTC, comment #2: 

I did a bit more exploration and found that the set command does not work as expected in the situation I mentioned:


figure
h = plot3([],[],[])
set (h, 'xdata', rand(10,1), 'ydata', rand(10,1), 'zdata', rand(10,1));


This doesn't result in adding a line to the new figure, not even in matlab, because the figure handle is empty so nothing is set. So this simplified my problem greatly when trying to fix this myself: I don't actually need a handle returned for each empty data set, just an empty array if there are no data sets. This is exactly the way that


h=plot([],[])


works as well, which does not error out in octave as plot3 does. A simple fix is then to add


retval = [];


somewhere near the top of plot3.


Marshall <marsian>
Mon 26 Feb 2018 05:12:21 PM UTC, comment #1: 

I'm marking this as "Matlab Compatibility" and lowering the priority as there are many, many workarounds.

As a start, a typical way is to embed a special condition for the first frame in the animation.


for i = 1:num_frames
  ... calculate data ...
  if (i == 1)
    ## First frame, use plot to create figure and axes
    h = plot3 (xdata, ydata, zdata);
  else
    ## Update data to refresh plot with new animation frame
    set (h, "xdata", xdata, "ydata", ydata, "zdata", zdata);
  endif
endfor


Alternatively, use throwaway data since it is just going to be overwritten


h = plot3 (0,0,0);
for i = 1:num_frames
  ... calculate data ...
  ## Update data to refresh plot with new animation frame
  set (h, "xdata", xdata, "ydata", ydata, "zdata", zdata);
  endif
endfor


If for some reason the data really, really needs to be null at the start then you can make it so by passing property/value pairs in the plot3 call.


h = plot3 (0,0,0, 'xdata', [], 'ydata', [], 'zdata', [])



Rik <rik5>
Group administrator
Sat 24 Feb 2018 02:09:33 AM UTC, original submission:  


handle = plot3([],[],[])


produces the error


error: value on right hand side of assignment is undefined


This code runs without error in Matlab. This command can be used to produce a plot handle which can later be used with set(handle, ...) to set x, y, and z data [for animations...].

Marshall <marsian>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by marsian (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-02 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2018-02-26 rik5 Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        Item GroupUnexpected Error or Warning Matlab Compatibility

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code