bugGNU Octave - Bugs: bug #55481, Plotting differences from Matlab...

 
 

bug #55481: Plotting differences from Matlab at 5.0 release

Submitter:  Rik <rik5>
Submitted:  Tue 15 Jan 2019 08:38:38 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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 20 Jan 2019 04:54:13 AM UTC, comment #25: 

I'm going to close this report.  There is a bug open about the problems with printing modifying the plot view (bug #55500) and one about the direction of normals (bug #55493).

Rik <rik5>
Group administrator
Sun 20 Jan 2019 04:44:33 AM UTC, comment #24: 

I changed dump_demos to use the viridis colormap (https://hg.savannah.gnu.org/hgweb/octave/rev/2ae2dcf0f4d5)

Rik <rik5>
Group administrator
Sat 19 Jan 2019 06:03:21 AM UTC, comment #23: 

I changed the dump_demos script to use the same ColorOrder as the rest of Octave (https://hg.savannah.gnu.org/hgweb/octave/rev/16f18b0ef642).

Rik <rik5>
Group administrator
Thu 17 Jan 2019 05:46:29 PM UTC, comment #22: 

I filed a bug about printing modifying the camera view, aspect ratio, etc. as bug #55500.  It isn't unique to printing; Using the mouse to rotate the plot will also cause things to go haywire.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 07:58:58 PM UTC, comment #21: 

@Markus: If the results are do approximations then using a finer grid should help.  I changed light demo #5 from


 [x,y,z] = meshgrid (-.2:0.04:.2, -.2:0.04:.2, -.2:0.04:.2);
 val = (x.^2 + y.^2 + z.^2);


to


 [x,y,z] = meshgrid (-.2:0.01:.2, -.2:0.01:.2, -.2:0.01:.2);
 val = (x.^2 + y.^2 + z.^2);


This changes the number of points in val from 1331 to 68921.  When I run the light demo on Matlab and Octave they now appear the same.  So, that seems to be the way forward.

For demo #5 I checked in a changeset (https://hg.savannah.gnu.org/hgweb/octave/rev/8bed6950ddde) where instead of the range operator I use linspace and I increased the number of points from 11 to 12.  This produces results which match those of Matlab.


rng = linspace (-0.2, +0.2, 12);
[x,y,z] = meshgrid (rng);


It might be useful to replace the range operator in other demo blocks of light as well, but #5 was the most glaring to me.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 07:45:18 PM UTC, comment #20: 

I filed bug #55493 for the issue with normals pointing in "random" directions before calling isonormals.

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jan 2019 07:27:28 PM UTC, comment #19: 

The different colors are a consequence of the dump_demos.m script.  There is this bit:


 ## Create script beginning (close figures, etc.)
  fid = fopen (mfile, "w");
  fprintf (fid, "%% DO NOT EDIT!  Generated automatically by dump_demos.m\n");
  fprintf (fid, "function %s ()\n", funcname);
  fprintf (fid, "set (0, 'DefaultAxesColorOrder', ...\n");
  fprintf (fid, "  [ 0.00000   0.00000   1.00000 ;\n");
  fprintf (fid, "    0.00000   0.50000   0.00000 ;\n");
  fprintf (fid, "    1.00000   0.00000   0.00000 ;\n");
  fprintf (fid, "    0.00000   0.75000   0.75000 ;\n");
  fprintf (fid, "    0.75000   0.00000   0.75000 ;\n");
  fprintf (fid, "    0.75000   0.75000   0.00000 ;\n");
  fprintf (fid, "    0.25000   0.25000   0.25000 ]);\n");
  fprintf (fid, "close all\n");
  fprintf (fid, "more off\n");
  fprintf (fid, "diary diary.log\n");


This ensures that we get reproducible results between Octave and Matlab.  However, Octave has moved to a different ColorOrder.


octave:1> get (0, 'DefaultAxesColorOrder')
ans =

   0.00000   0.44700   0.74100
   0.85000   0.32500   0.09800
   0.92900   0.69400   0.12500
   0.49400   0.18400   0.55600
   0.46600   0.67400   0.18800
   0.30100   0.74500   0.93300
   0.63500   0.07800   0.18400


We could just update the dump_demos.m script with the new values.  I think, however, that we might have had a reason for doing this because the first three lines are primary colors of blue, green, and red.  This stark a difference is easy to spot.

I guess I would advocate doing the experiment and updating the DefaultAxesColorOrder and then running dump_demos with just one toolkit (qt) on Linux and see if the result appears visually okay.  If it does then we can make the change permanently.

I also think that we need to include the viridis colormap and set it as the default colormap.  The default used by Matlab is similar to viridis, but not identical.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 07:09:19 PM UTC, comment #18: 

Other noticeable differences are in
- demo camlookat 1: different zoom levels (I cant't reproduce on screen)
- demo camorbit 1: different view angle
- demo camtarget 1: different plotboxaspectratio
- demo camva 1: completely different zoom level between fltk and qt (I can't reproduce on screen)
- demo camzoom 1: completely different zoom level between fltk and qt (I cant't reproduce on screen)
- demo legend 4-9 and 11: The colors in the legend text don't correspond to the actual line colors.
- demo light 1, demo light 15 and others: different auto axis limits

Maybe all of the differences in zoom level come down to differences in scaling when plotting with painters vs. opengl. Maybe a bug in one of the two renderers?

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jan 2019 06:51:52 PM UTC, comment #17: 

To make sure that we are talking about the same thing in demo light 5: Are you referring to the outline of the specular reflex (the bright white spot)?
I'd say that outline is shaped slightly differently because Matlab seems to use a different algorithm to generate the faces for "sphere" (better visible in "demo reducepatch"). That leads to the faces being inclined slightly differently in Octave and in Matlab which in turn leads to slightly different lighting effects.

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jan 2019 05:16:35 PM UTC, comment #16: 

@Markus: Go ahead and open up a report (I'm not sure it's a bug) about isonormals.  That doesn't need to be fixed before the 5.0 release.

It is possible that we are doing the lighting correctly between "lit" and "unlit" and it is Matlab that is in error.  Let's assume that is true and ignore those for now.

The last bit is "demo light 5".  The difference is most clear on the lower right sphere.  In Octave, the reflection is pointed down and left.  In Matlab, the reflection is pointed down and right.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 07:59:42 AM UTC, comment #15: 

Wrt the isonormals demo: Matlab seems to point some of the automatically calculated normals in the opposite direction from what Octave does. That should probably be handled in a dedicated bug.

Wrt the light demos: I don't see what you describe in demo 5. Could you please elaborate?
In the right column of demo 9 and 10, it looks like "unlit" has the same effect as "lit" in Matlab (like you already wrote in comment #0). I consider this a bug in Matlab and believe Octave is actually doing better in this case.
To be honest, I don't know what Matlab is doing in the upper left subplot of demo 10. It doesn't look "reverselit" to me...

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jan 2019 06:19:21 AM UTC, comment #14: 

It looks like the light demos and the isonormal ones are the only remaining cases to investigate.  That's not my area so I'll leave it to someone else.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 06:17:42 AM UTC, comment #13: 

I tested the scatter demo #3 and it works fine.  I think there may have simply been trouble when the script to create the plots had to be split in to multiple pieces in order to work on Matlab.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 04:03:31 AM UTC, comment #12: 

I changed the demos in plotyy.m and copyobj.m that used direct indexing of the value returned from the function call to get() since Matlab can't handle this syntax (https://hg.savannah.gnu.org/hgweb/octave/rev/4744a878c43f).

Rik <rik5>
Group administrator
Wed 16 Jan 2019 03:38:28 AM UTC, comment #11: 

The regression with printing rotated text is pretty serious.  I filed a new bug report about that (bug #55485).

Rik <rik5>
Group administrator
Wed 16 Jan 2019 03:25:48 AM UTC, comment #10: 

I changed the demo code for ezplot3 not to use a scalar argument 'N' to specify the number of points since this seems to be an Octave-specific option.  See https://hg.savannah.gnu.org/hgweb/octave/rev/fce57b70768b.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 01:37:18 AM UTC, comment #9: 

I changed our %!demo code to use Matlab syntax (https://hg.savannah.gnu.org/hgweb/octave/rev/9728b61ef67e).  It should work the next time we run compare_plot_demos.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 12:47:01 AM UTC, comment #8: 

Another difference to consider fixing.


demo plotmatrix 1
 ## Matlab chooses to hide the xlabels and ylabels of subplots in the 3x3
 ## array in order to better show the data.  Also, for the subplots with
 ## histograms the axis tick marks are disabled.  See plotmatrix.m


Rik <rik5>
Group administrator
Wed 16 Jan 2019 12:40:33 AM UTC, comment #7: 

I filed bug #55484 about a regression in the printing of dashed lines with the qt toolkit only.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 12:26:46 AM UTC, comment #6: 

We don't need to fix polar demo #2.  Octave is more sophisticated than Matlab and simply knows how to plot complex input in polar coordinates.

Rik <rik5>
Group administrator
Wed 16 Jan 2019 12:25:53 AM UTC, comment #5: 

I filed a new bug about 3-D ticklengths (bug #55483).  In the meantime, I scaled the lengths produced by Octave's algorithm to get better visuals (https://hg.savannah.gnu.org/hgweb/octave/rev/acefc0bca74a).

Rik <rik5>
Group administrator
Wed 16 Jan 2019 12:00:14 AM UTC, comment #4: 

I changed polar to have light grey axes lines as in Matlab (https://hg.savannah.gnu.org/hgweb/octave/rev/58e7a737c82b).

Rik <rik5>
Group administrator
Tue 15 Jan 2019 11:59:36 PM UTC, comment #3: 

No need to fix fplot, I think it is more useful to add the legend.

Rik <rik5>
Group administrator
Tue 15 Jan 2019 11:50:20 PM UTC, comment #2: 

Rik,

I ran the script on dev system and all the plots looked
just fine. As I am sure you know, there has long been
a claim that Octave plotting was much less effective
than Matlab's. This was, from my view, pretty sad since
Matlab's plotting is far from what should be available.

So, congratulations to all who helped with this!!!

Michael

Michael Godfrey <godfrey>
Group Member
Tue 15 Jan 2019 09:57:07 PM UTC, comment #1: 
Rik <rik5>
Group administrator
Tue 15 Jan 2019 08:38:38 PM UTC, original submission:  

Visual comparisons of plots from the various graphics toolkits (fltk, gnuplot, qt) as well as Matlab are available at:

https://drive.google.com/file/d/16txXTl2k6-nrHQzWSFhHj2J35Wju91BK/view?usp=sharing


Basic things that I have noticed

demo bar 1 : axes ticks are shown on top of the bars
demo text 1 : rotated text is only valid for 0, 90, 180, 270 degrees.  This is not the case for the FLTK toolkit which also uses gl2ps
demo polar 1 : The axes lines are semi-transparent in Matlab, as they are for Octave on a rectangular axes
demo copyobj 1 : Completely fails on Matlab, so we must have the wrong syntax
demo errorbar 2 : Completely different plot.
demo ezplot 3 : Complaint from Matlab about undefined variable 'T'
demo annotation 3 : There are more arrowhead styles available for Matlab.
demo box 3 : The 3-D ticklengths are overly large.  This is a problem with all 3-D plots.
demo ezplot3 1 : Completely different plot
demo ezplot 1 : Matlab replaces special text, like pi, with '\pi' so that tex interpreter can produce symbols.
demo fplot 1 : Matlab doesn't automatically add a legend, but I actually like having one.
demo isonormal 1 : Upper left plot is different from Matlab.
demo stem 1 : Matlab draws axes box for stem plots.  Could turn that on very easily.
demo light 5 : It looks like the reflections in the right column are in the opposite direction from Matlab (multiplication by -1 maybe?)
demo light 9 : Matlab's "lit" and "unlit" look the same.
demo line 1 : No Matlab plot so we have incorrect syntax somehow.
demo polar 2 : Matlab plot is completely different.
demo polar 4 : polar axes grid lines are under, rather than over, polar plot.
demo scatter 3 : Matlab fails because the color argument C is somehow incorrect.

Rik <rik5>
Group administrator

 

(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 mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by rik5 (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
    2019-01-20 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2019-01-16 rik5 Carbon-Copy- Added mmuetzel
    2019-01-16 rik5 SummaryPlotting differences from Matlab Plotting differences from Matlab at 5.0 release
    2019-01-15 rik5 StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code