Menu ▾ ▴

#2905 Lines outside of graph bounds with bounded autoscaling

None
pending-fixed
nobody
None
2 days ago
2026-11-19
Ahnolds
No

Minimal example, tested in both gnuplot 5.4 and 6.0:

set term dumb
set yrange [: * < 40]
plot 35 - x

Results in something like the following (or attached png if run with a png terminal)

                  ****
  40 +---------------------------------------------------------------------+
     |                 +***             +                 +                |
  38 |-+                   ***                              35 - x *******-|
     |                        ***                                          |
     |                           ***                                       |
  36 |-+                           ****                                  +-|
     |                                ***                                  |
  34 |-+                                 ***                             +-|
     |                                      ***                            |
     |                                         ***                         |
  32 |-+                                          ***                    +-|
     |                                              ***                    |
  30 |-+                                               ***               +-|
     |                                                    ***              |
     |                                                       ***           |
  28 |-+                                                        ***      +-|
     |                                                             ***     |
  26 |-+                                                             *** +-|
     |                                                                  ***|
     |                 +                +                 +                |
  24 +---------------------------------------------------------------------+
    -10               -5                0                 5                10

Disabling autoscaling of the lower bound makes it correctly graph only in the bounded region. Plotting something that remains inside the bounded region before the thing that goes outside the region (e.g. "plot x + 10, 35 - x" in this example) makes it graph correctly.

1 Attachments

Discussion

  • Ahnolds

    Ahnolds - 2026-11-19
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,7 +2,7 @@
    
     ~~~
     set term dumb
    -set yrange [* : 30 &lt; * &lt; 40]
    +set yrange [: * &lt; 40]
     plot 35 - x
     ~~~
    
    • Group: -->
    • Priority: -->
     
  • Ahnolds

    Ahnolds - 2 days ago

    Found the issue using claude. When autoscaling starts, min is initialized to VERYLARGE. The first data point is then guaranteed to be set as the min value. However, if it's above the maximum allowable upper bound, so the max is clamped appropriately. This temporarily results in min > max, but the points are still considered as INRANGE, so they are drawn. When eventually a data point that is actually in the intended range is found, min is updated so that it's sane (less than max), and the final axis is drawn correctly.

    Patch generated accordingly, passes locally

     
  • Ethan Merritt

    Ethan Merritt - 2 days ago
    • status: open --> pending-fixed
     
  • Ethan Merritt

    Ethan Merritt - 2 days ago

    Applied. Thanks.

     

Log in to post a comment.