bugGNU Octave - Bugs: bug #57800, view command produces different...


bug #57800: view command produces different results in MATLAB and Octave

Submitted by:  SCI9 <sci9>
Submitted on:  Wed 12 Feb 2020 03:50:58 PM UTC  
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


Sun 16 Feb 2020 11:56:56 PM UTC, comment #3: 

I overhauled the view function in this changeset: https://hg.savannah.gnu.org/hgweb/octave/rev/11072ea6a16c.  This included a fix for this bug report which will become available in the 6.1 release of Octave.

Rik <rik5>
Project Administrator
Thu 13 Feb 2020 01:54:19 AM UTC, comment #2: 

The issue is how to handle the conversion from a point (X,Y,Z) to an azimuth, elevation pair.  Matlab converts

view (0, 0, 1) -> az = 0, el = 90

while Octave converts this to

view (0, 0, 1) -> az = 90, el = 90

A point on the Z-axis (x = 0, y = 0) does not specify any particular azimuth when converted to spherical coordinates.  The software just needs to pick a value and it appears Matlab is using one convention and Octave another.

Working out the rules for Matlab would be useful.

Rik <rik5>
Project Administrator
Wed 12 Feb 2020 04:18:03 PM UTC, comment #1: 

I can reproduce on Octave 4.4.1 and 5.2 on macOS.

If you throw in an `xlabel('X Axis')` it clarifies things: Looks to me like the X and Y axes are getting swapped from where I would expect them to be.

Andrew Janke <apjanke>
Wed 12 Feb 2020 03:50:58 PM UTC, original submission:  

The commands  `shading faceted` and `shading interp` produce different figures in MATLAB and Octave.

Consider this code:

    [X, Y] = meshgrid(0:2, 0:2);
    Z = magic(3);




    subplot(1, 3 ,1);
    axis xy
    yticklabels({'0', '1', '2'})
    xticklabels({'0', '1', '2'})


    surf(X, Y, Z);
    shading faceted;
    title('surf(X, Y, Z); shading faceted;');


    surf(X, Y, Z);
    shading interp;
    title('surf(X, Y, Z); shading interp;');

This is the result in MATLAB:

And the result generated by Octave:


MATLAB generates a correct figure. What is wrong with this Octave figure?

What is the reason we get two different outputs? Is it an issue with to the `view` command?

SCI9 <sci9>


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

Attach Files:

Attached Files


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 apjanke (Posted a comment)
  • -email is unavailable- added by sci9 (Submitted the item)

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-02-16 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2020-02-13 rik5 StatusNone => Confirmed
        Release5.2.0 => dev
    2020-02-12 sci9 Attached File- => Added octave.png, #48395

    Back to the top

    Powered by Savane 3.5