bugGNU Octave - Bugs: bug #35216, line(x,y,'propname','propvalue')...

 
 

bug #35216: line(x,y,'propname','propvalue') throw error

Submitter:  Ben Abbott <bpabbott>
Submitted:  Mon 02 Jan 2012 01:00:07 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 06 Apr 2012 11:23:13 PM UTC, comment #10: 

I added a demo and pushed the changeset.

http://hg.savannah.gnu.org/hgweb/octave/rev/8150ccfffa22


Ben Abbott <bpabbott>
Group Member
Fri 06 Apr 2012 04:24:45 PM UTC, comment #9: 

Thanks.  I now have two examples where one works and the other fails.  I'm attaching a patch that is based on your work so you should get the credit for it.  Can you verify that it also works for you and commit it?

The examples I used were


line ([34 40; 34 40]', [0 35; 0 35]', 'color', 'r');   # passes
line ([34 40; 34 40]', [0 35]', 'color', 'r'); # fails if no patch





(file #25602)

Rik <rik5>
Group administrator
Fri 06 Apr 2012 04:06:48 PM UTC, comment #8: 

Which example ?

The one below ?


line ([34 40; 34 40], [0 35; 0 35], 'color', 'r')


This should just produce two points. Perhaps a better example is


line ([34 40; 34 40]', [0 35; 0 35]', 'color', 'r')


Ben Abbott <bpabbott>
Group Member
Fri 06 Apr 2012 03:58:19 PM UTC, comment #7: 

Okay.  I gather now that the vectors are column vectors rather than row vectors.  But according to comment #3, there was no problem when plot was used instead of line.  However, I don't even get a line when I try the example


Rik <rik5>
Group administrator
Fri 06 Apr 2012 03:37:40 PM UTC, comment #6: 

Rik,

I tried the version below on both 3.4.0 and the default branch. Both gave me the same result.


plot ([34 35; 35 36], [0 15; 5 20], 'o-b')


The result is the same as


plot ([34; 35], [0; 5], 'o-b', [35; 36], [15; 20], 'o-b')


The reason you saw three points is because your version was equivalent to


plot ([34; 35], [0; 0], 'o-b', [40; 40], [35; 35], 'o-b')


Ben Abbott <bpabbott>
Group Member
Fri 06 Apr 2012 03:17:20 PM UTC, comment #5: 

Ben, we've sort of ignored this bug report for a while.

I think something else may have crept into the code.  Starting with a current tip and no patches applied if I try


plot ([34 40; 35 40], [0 35; 0 35], 'o-b')


I don't get two lines, just 3 points.  This was supposed to work according to comment #3.

Rik <rik5>
Group administrator
Tue 21 Feb 2012 12:42:30 AM UTC, comment #4: 

I see.  Well it still looks reasonable to use your approach but I would shift to using bsxfun rather than broadcasting.  This will avoid having to set and restore the broadcasting warning state.

The following works:


cellfun (@(x) bsxfun (@times, b, x), varargin(n), "uniformoutput", false)


The try/catch architecture is still needed.

Rik <rik5>
Group administrator
Tue 21 Feb 2012 12:10:27 AM UTC, comment #3: 

It is more than just comparing sizes. For compatibility the sizes (up to 2d) need a broadcast sort of functionality. In addition, the prop-name & prop-value pairs need to be supported.

Both the examples below work for Matlab. In Octave, both work if "line" is replaced by "plot".


line ([34 40; 34 40], [0 35; 0 35], 'color', 'r')



line ([34 40; 34 40], [0 35], 'color', 'r')




Ben Abbott <bpabbott>
Group Member
Mon 20 Feb 2012 09:09:29 PM UTC, comment #2: 

Ben,

If I understand your changeset you are just looking to see whether the number of elements for the X, Y, and Z arguments are the same.  I think you can do this succinctly without broadcasting by using the isequal function which is equivalent to 'a == b == c == ...' and only returns true if everything is equal.

Looking at changeset-1.patch, I think the whole thing could be simplified to


nums = cellfun (@numel, varargin(1:num_data_args));
if (! isequal (nums{:}))
  error ("line: number of X, Y, and Z points must be equal");
endif


Rik <rik5>
Group administrator
Mon 02 Jan 2012 11:29:36 PM UTC, comment #1: 

I'm not sure what the correct solution here is.

Recently Jordi added broadcasting to Octave. This feature is well suited toward plot functions.

Should each plot function handle the broadcasting independently, of should a single function be written for that purpose?

I've attaching two changesets. changeset-1.patch handles everything. The second version, changeset-2.patch, relies on a second function, broadcast(). I'm also attaching a prototype broadcast.m. However, I think it should be written in c++, so it isn't included as part of the changeset.

(file #24725, file #24726, file #24727)

Ben Abbott <bpabbott>
Group Member
Mon 02 Jan 2012 01:00:07 PM UTC, original submission:  

The docs indicate that line(x,y,z,name,value) is valid syntax. Without "z" an error results.


figure(1)
clf
line([34 40; 34 40], [0 35; 0 35], 'color', 'r')
error: invalid value for array property "xdata"
error: set: expecting argument 2 to be a property name
error: set: expecting argument 4 to be a property name


In addition,


line ([34 40; 34 40], [0 35], 'color', 'r')
error: line: number of X, Y, and Z points must be equal
error: called from:


Both of these work in ML R2011b.

Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #25602:  bug35216.patch added by rik5 (756B - application/x-download)
file #24725:  changeset-1.patch added by bpabbott (1KiB - application/octet-stream)
file #24726:  broadcast.m added by bpabbott (1KiB - application/octet-stream)
file #24727:  changeset-2.patch added by bpabbott (1KiB - application/octet-stream)

 

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 bpabbott (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-04-06 bpabbott StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2012-04-06 rik5 Attached File- Added bug35216.patch, #25602
    2012-01-02 bpabbott Attached File- Added changeset-1.patch, #24725
        Attached File- Added broadcast.m, #24726
        Attached File- Added changeset-2.patch, #24727
        StatusNone Patch Submitted

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code