bugGNU Octave - Bugs: bug #63033, "axis tight" includes...


bug #63033: "axis tight" includes x-data in limit calculation for which the y-data is NaN

Submitter:  Johannes Pfeifer <jpfeifer>
Submitted:  Thu 08 Sep 2022 01:19:54 PM UTC
Category:  Plotting Severity:  1 - Wish
Priority:  3 - Low Item Group:  Matlab Compatibility
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

Fri 16 Sep 2022 12:22:51 AM UTC, comment #1: 

Confirmed.  Re-titling the bug report to be more precise about the issue.

Sample code

plot (1:10, [1:9, NaN])
axis tight

The explanation is rather simple.  When Octave calculates limits for "axis tight" it looks at each axis individually.  In the sample code, the x-data has a minimum of 1 and a maximum of 10 so that is what Octave sets the axis limits to.  Apparently Matlab also checks whether the corresponding y-value is finite.  I tried two variations in Matlab and the limit is 9 in each case.

plot (1:10, [1:9, NaN])
plot (1:10, [1:9, Inf])

But, things aren't always straightforward even in Matlab.  This code produces a line at 45 degrees from 1:9.  There are no line segments after x == 9, and yet the limits of the plot are set at 1 and 11.

plot (1:11, [1:9, NaN, 9])
axis tight

I know why it does that, but it still seems odd since there is no visual data past 9.

Marking as a low priority since there are easy workarounds such as calling xlim or axis with limits that look good to the programmer.

Rik <rik5>
Group administrator
Thu 08 Sep 2022 01:19:54 PM UTC, original submission:  

plot(1:10,[zeros(9,1); NaN])
axis tight

in Matlab cuts off the NaN and set the xlim to [0, 9], while in Octave the NaN is kept and the xlim is [0,10]

Johannes Pfeifer <jpfeifer>


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

Attach Files:

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 rik5 (Posted a comment)
  • -email is unavailable- added by jpfeifer (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-16 rik5 Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Release7.2.0 dev
        Operating SystemMicrosoft Windows Any
        Summaryaxis tight does not ignore NaN "axis tight" includes x-data in limit calculation for which the y-data is NaN

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code