bugGNU Octave - Bugs: bug #40114, pcolor with NaN produces black...

 
 

bug #40114: pcolor with NaN produces black grid cells and invalid EPS files

Submitter:  None
Submitted:  Thu 26 Sep 2013 07:45:25 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Alexander Barth Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 08 Oct 2013 06:49:01 PM UTC, comment #6: 

Indeed, it works. Thanks a lot!

Alexander Barth <abarth>
Tue 08 Oct 2013 03:02:41 PM UTC, comment #5: 

I independently came to the same conclusion about how to color patches.  I checked in a change 18 hours ago (http://hg.savannah.gnu.org/hgweb/octave/rev/c3aadd228c37) that does what your patch does.  I also expanded it to edgecolor which was also not being treated correctly.  Try a Mercurial version >= to 17589:c3aadd228c37.  I ran your test_pcolor script and it produces the same results as Matlab.

Rik <rik5>
Group administrator
Tue 08 Oct 2013 09:26:31 AM UTC, comment #4: 

Here is the patch.

(file #29322)

Alexander Barth <abarth>
Tue 08 Oct 2013 09:25:34 AM UTC, comment #3: 



I tested the current version of octave with change (http://hg.savannah.gnu.org/hgweb/octave/rev/e48a22b94727).
There are still difference in the way NaNs are handeld compared to matlab (R2013a). Matlab tries to plot as much as possible while this is not the case for the current dev version of octave (compare pcolor_octave_current.png and pcolor_matlab.png generated by test_pcolor.m).
In particular a NaN in the parameter c is handeld different than a NaN in the coordinates. Therefore I think we should not use the clip variable in both cases.

The attached patch (pcolor_NaN2.patch) makes the behaviour compatible (see pcolor_octave_with_patch_NaN2.png).

Can somebody have a look to the new patch?
Thanks!


(file #29318,

Alexander Barth <abarth>
Thu 03 Oct 2013 11:44:11 PM UTC, comment #2: 

I applied a variant of the first patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/e48a22b94727).  The renderer now checks the cdata for NaNs in addition to x,y,z data.  Closing report.

Rik <rik5>
Group administrator
Mon 30 Sep 2013 02:59:28 PM UTC, comment #1: 


I don't think that the patch by novalis (fix-40114.patch), i.e. replacing all NaNs by zeros would be a good solution, because these additional zeros will be actually plotted. One could not distinguish a real zero from a NaN.

Alexander Barth <abarth>
Thu 26 Sep 2013 07:45:25 PM UTC, original submission:  


If a matrix containing a NaN is plotted with pcolor, the corresponding grid cell is black, while in matlab such elements are not plotted (they appear white since the default background is white).

If the plot is saved as an EPS file, the resulting file containts a "nan" and cannot be opened by ghostscript (which is used to create a PNG file for example).

The following command

 pcolor([NaN 1 2; 3 4 5; 6 7 8])
 print -dpng test.png

creates thus an error:

Error: /undefined in nan
Operand stack:
   --nostringval--   74.88   223.56
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   --nostringval--   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1167/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--   --dict:40/64(L)--
Current allocation mode is local
GPL Ghostscript 9.05: Unrecoverable error, exit code 1


I got this error for the current development version (changeset: 17497:96cf8ee3440e) and octave 3.6.4.

The special value "NA" produces the same error, but not Inf.

The code in gl-render.cc (function opengl_renderer::draw_surface)  checks only if the grid arrays x,y or z contain a NaN. The attached patch adds additional checks. I have tested it with NaN and NA for flat and interpolated shading.





Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #29322:  pcolor_NaN2.patch added by abarth (1KiB - text/x-patch)
file #29318:  test_pcolor.m added by abarth (702B - text/x-objcsrc)
file #29319:  pcolor_octave_current.png added by abarth (167KiB - image/png)
file #29321:  pcolor_matlab.png added by abarth (49KiB - image/png)
file #29256:  fix-40114.patch added by novalis (522B - text/x-patch - A patch for this)
file #29232:  pcolor_NaN.patch added by None (1KiB - text/x-patch)

 

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 abarth (Posted a comment)
  • -email is unavailable- added by novalis (Updated the item)
  • -email is unavailable- added by None (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-08 abarth Attached File- Added pcolor_NaN2.patch, #29322
    2013-10-08 abarth Attached File- Added test_pcolor.m, #29318
        Attached File- Added pcolor_octave_current.png, #29319
        Attached File- Added pcolor_octave_with_patch_NaN2.png, #29320
        Attached File- Added pcolor_matlab.png, #29321
    2013-10-03 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2013-09-28 novalis Attached File- Added fix-40114.patch, #29256
    2013-09-26 None Attached File- Added pcolor_NaN.patch, #29232

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code