bugGNU Octave - Bugs: bug #37501, contour and contourf...

 
 

bug #37501: contour and contourf incorrectly/incompatibly handle NaN values

Submitter:  Muhali <muhali>
Submitted:  Thu 04 Oct 2012 12:14:45 PM UTC
   
 
Category:  Plotting Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 19 Apr 2023 01:12:25 AM UTC, comment #8: 

I'm noticing though that in general neither contour nor contourf compatibly handle NaN discontinuities in the data, whether on endpoints or not.

In the matlab docs for contour and contourf, they include the example:


Z = peaks;
Z(:,26) = NaN;
contour(Z);

(and same with contourf(Z))  the result should have a vertical gap in the center of the plot.  Octave ignores the missing data and plots through that gap.  See attached comparison images.

seems this is a more general issue of NaN handling than just how it behaves on the boundary. updating title.


Nicholas Jankowski <nrjank>
Group Member
Wed 19 Apr 2023 01:03:37 AM UTC, comment #7: 

looking at v8.2.0, contourf output seems the same as in comment #2.  Rik's stripped out version looks more complete, (the data index was missing a : though)


contourf (X(:,2:end-1), Y(:,2:end-1), data(:,2:end-1))


checking matlab, both images with the full data and trimmed data look the same as Octave's trimmed data.

Nicholas Jankowski <nrjank>
Group Member
Wed 16 Nov 2016 07:24:21 PM UTC, comment #6: 

Bug is still present in contourf with the current development version of Octave.

Mike Miller <mtmiller>
Group Member
Wed 31 Oct 2012 04:34:13 PM UTC, comment #5: 

I notice that the 2-D data you are plotting with contourf has columns of NaN values on the far left and far right.  If I strip out the NaNs the contourf plot looks exactly right.


contourf (X(:,2:end-1), Y(:,2:end-1), data(2:end-1))


It would be nice for Octave to behave better in this situation, but it is probably somewhat difficult to untangle.  You might want to just use the workaround of removing the NaNs from your data.

For those interested, the file to check is scripts/plot/private/__contour__.m.  Maybe we want to add a grid around the plotted data with a value that is always numerical and always small, such as -Inf, so that the contours will always close.  Then when plotting we can remove the grid.  This way the NaNs on the border will still close.

Rik <rik5>
Group administrator
Thu 04 Oct 2012 03:41:45 PM UTC, comment #4: 


> Which graphics backend are you using?


For the attached figures fltk, but I see the same with gnuplot.

Muhali <muhali>
Thu 04 Oct 2012 03:35:29 PM UTC, comment #3: 

Which graphics backend are you using?

Michael Godfrey <godfrey>
Group Member
Thu 04 Oct 2012 02:51:09 PM UTC, comment #2: 

The original print figure, which was from my office machine, is attached (contour.png). On my home machine I cannot reproduce it either, and interestingly, not even when I use my office machine remotely.

But I can reproduce the contourf behavior,


contourf(X, Y, data)


with a similar straight line from NW to S as in contour.png (contourf.png attached).



Muhali <muhali>
Thu 04 Oct 2012 01:17:05 PM UTC, comment #1: 

I can't see the problem you're describing. Can you please post a few screenshots and images, perhaps annotating them with the precise problem? Also, can you test both gnuplot and fltk?

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Thu 04 Oct 2012 12:14:45 PM UTC, original submission:  

Using the attached foo.txt and doing


load foo.txt
contour(X, Y, data)
print foo.png


the plot figure is different from the print figure. The print figure seems to have the same error as the plot from using contourf.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #54638:  contourcomp.png added by nrjank (189KiB - image/png - matlab2023a/octave8.2.0 comparison with NaN gap )
file #26699:  contour.png added by muhali (73KiB - image/png)
file #26700:  contourf.png added by muhali (113KiB - image/png)
file #26697:  foo.txt added by muhali (31KiB - text/plain)

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by muhali (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 17 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-19 nrjank Attached File- Added contourcomp.png, #54638
        StatusPostponed Confirmed
        Operating SystemGNU/Linux Any
        Summarycontourf incorrect when NaN present on boundary contour and contourf incorrectly/incompatibly handle NaN values
    2022-04-09 jwe Item GroupNone Incorrect Result
    2019-11-26 rik5 Dependencies- bugs #57310 is dependent
    2016-11-18 mtmiller Dependencies- bugs #35033 is dependent
    2016-11-16 mtmiller Severity3 - Normal 2 - Minor
        StatusConfirmed Postponed
        Release3.6.3 dev
    2014-07-14 rik5 Dependencies- bugs #42766 is dependent
    2012-10-31 rik5 StatusNeed Info Confirmed
        Summarycontour produces incorrect print figure contourf incorrect when NaN present on boundary
    2012-10-04 muhali Attached File- Added contour.png, #26699
        Attached File- Added contourf.png, #26700
    2012-10-04 jordigh StatusNone Need Info
    2012-10-04 muhali Attached File- Added foo.txt, #26697

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code