bugGNU Octave - Bugs: bug #47149, line ([x1, x2]', [y1, y2]) is one...

 
 

bug #47149: line ([x1, x2]', [y1, y2]) is one line in Matlab but not Octave

Submitted by:  Lachlan Andrew <lachlan>
Submitted on:  Mon 15 Feb 2016 02:12:16 AM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: In ProgressAssigned to: Lachlan Andrew <lachlan>
Originator Name: LachlanOpen/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 26 Aug 2016 08:44:17 AM UTC, comment #10:

@Lachlan,
Are you still planning to work on this?

I've regularly applied the cset but I've recently discovered that it gives rise to FAILs in copyobj.m and hgsave.m.
Maybe it is just the way the tests are set up, but I have no time for looking into it for a while.

Philip Nienhuis <philipnienhuis>
Project Member
Tue 03 May 2016 08:20:19 AM UTC, comment #9:

I just noticed that there is overlap between this bug report and bug #39036. I'm adding a link, and will look into merging the patches.

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.
Tue 05 Apr 2016 09:06:01 PM UTC, comment #8:

I finally got round to testing this patch the last days. AFAICS it works OK.

Can this be pushed?

Philip Nienhuis <philipnienhuis>
Project Member
Fri 19 Feb 2016 11:28:42 PM UTC, comment #7:

The attached patch supports all of the forms that Philip proposed, and leaves the properties of the lines as close to Matlab compatible as I could manage.

(file #36402)

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.
Fri 19 Feb 2016 12:22:59 AM UTC, comment #6:

Good point, jwe. I was totally forgetting that it is possible to access the data again.

The reason I wasn't getting any line was that I was drawing vertical lines,

and so each line was reduced to a single point.

Fortunately, Matlab gives

so it seems we can just transpose the data -- much better than having to modify some subset of graphics toolkits to reinterpret the data.

Similar to your last example, Octave gives a diagonal line for the one-shot command

Thanks for all your guidance.

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.
Thu 18 Feb 2016 05:34:32 AM UTC, comment #5:

I see this behavior:

Then if I change the axis limits, the horizontal lines appear in the plot window.

So it looks like the problem is that line is doing something similar to broadcasting and creating two line objects instead of recognizing that there are two vectors of the same length.

When fixing this, it's important to make sure that the x and y data stored in the line object are oriented in a Matlab-compatible way. Do they retain their original orientation, or is one transposed so they are both row (or column) vectors?

I see that the following appears to work, so I think the bug is just in making line recognize the case of vectors with different orientations.

John W. Eaton <jwe>
Project Administrator
Thu 18 Feb 2016 02:20:40 AM UTC, comment #4:

Thanks, Philip. I'll have a go at coding that somewhat efficiently.

Note that the bug report was about the low-level "line" command rather than high-level "plot" command. I think that Octave's "plot" already handles these rotations, but "line" doesn't. (I checked your examples in Matlab, and it handles line flexibly too.) I just don't want to put too much additional checking into "line" because a "stem" command can call it hundreds of times, last I checked.

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.
Wed 17 Feb 2016 04:39:18 PM UTC, comment #3:

Lachlan, in your title example the length of the vector matches. That is all that Matlab needs.

What works (in ML 2014a) is e.g. (by the absence of error messages),

(note that in the last example the plot is rotated 90 degrees relative to the previous examples).

But ML has limitations:

...so one of the arguments to plot must be a vector, the other can be a matrix of which at least one dimension must have the same length as the vector argument.

AFAICS Matlab first tries to match dimensions/orientations as specified on the command line/instruction, and if it finds no match, tries rotating arguments until it finds common lengths, otherwise fails with an error message.

Philip Nienhuis <philipnienhuis>
Project Member
Tue 16 Feb 2016 10:41:41 PM UTC, comment #2:

Thanks for checking, Philip. In the example I gave, neither dimension matches, but Matlab still draws the line. When I get to work, I'll check further.

Do we want to copy Matlab's forgiving behaviour exactly, partially or not at all? I'm in favour of copying whatever is quick to check for.

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.
Mon 15 Feb 2016 09:40:38 AM UTC, comment #1:

Matlab is very forgiving even if one is a matrix. AFAICS Matlab only checks which dimensions of the input vectors/matrices match and then use that for plotting.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 15 Feb 2016 02:12:16 AM UTC, original submission:

If all X, Y and Z are vectors of the same length, Matlab doesn't seem to care whether they are row or column vectors.

Octave plots nothing if X is a column and Y is a row.

Lachlan Andrew <lachlan>
Project MemberIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #36402:  bug_47149_line_x_y_transpose.cset added by lachlan (3KiB - application/octet-stream)
file #36339:  bug_line_x_y_transpose.cset added by lachlan (1KiB - application/octet-stream)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by philipnienhuis
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by lachlan (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 14 May 2016 01:22:06 AM UTClachlanStatusReady For Test=>In Progress
    Tue 03 May 2016 08:20:19 AM UTClachlanDependencies-=>Depends on bugs #39036
    Sun 17 Apr 2016 12:30:05 PM UTCphilipnienhuisCarbon-Copy-=>Added philipnienhuis
    Fri 19 Feb 2016 11:28:42 PM UTClachlanAttached File-=>Added bug_47149_line_x_y_transpose.cset, #36402
      StatusIn Progress=>Ready For Test
      Summaryline ([x1, x2]\', [y1, y2]) works in Matlab but not Octave=>line ([x1, x2]', [y1, y2]) is one line in Matlab but not Octave
    Thu 18 Feb 2016 02:20:40 AM UTClachlanStatusPatch Submitted=>In Progress
    Mon 15 Feb 2016 02:12:16 AM UTClachlanAttached File-=>Added bug_line_x_y_transpose.cset, #36339

    Back to the top


    Powered by Savane 3.1-cleanup1