Menu

#2829 plotting in table mode ignores x-range

None
open-not-a-bug
nobody
None
2025-09-19
2025-09-18
Anonymous
No

Hello,
running gnuplot 6.0pl3.

I noticed that plotting into a table does not respect the xrange given in the plot command.

Example:
Create a datafile or use this datablock:

$data << EOD
1 1
2 2
3 4
4 8
5 16
EOD

You can plot this data(block):

gnuplot plot $data with lp lt 4

or a part of it by giving a certain x-range in brackets:

gnuplot plot [2:4] $data with lp lt 4

However, if you print the data into a table, the xrange is ignored:

~~~gnuplot
set table $k
plot [2:4] $data with table
set table
print $k
~~~

results in this output:
1 1
2 2
3 4
4 8
5 16

I expected a different output:
2 2
3 4
4 8
consistent with the function plot above.

I consider this a bug.

What is your view on this?
Thanks.
Daniel

Discussion

  • Daniel Dan K.

    Daniel Dan K. - 2025-09-18

    I filed this ticket. Obviously, one can file bug reports without being logged in. I did not know this.

     
  • Ethan Merritt

    Ethan Merritt - 2025-09-18
    • status: open --> open-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2025-09-18

    From the documentation:

    gnuplot> help with table

    This discussion applies only to the special plot style with table.

    To avoid any style-dependent processing of the input data being tabulated
    (filters, smoothing, errorbar expansion, secondary range checking, etc),
    or to increase the number of columns that can be tabulated, use the keyword
    "table" instead of a normal plot style.
    In this case the output does not contain an extra column containing a
    flag i, o, u indicating inrange/outrange/undefined.
    The destination for output must first be specified with set table <where>.
    For example

      set table $DATABLOCK1
      plot <file> using 1:2:3:4:($5+$6):(func($7)):8:9:10 with table
    

    Because there is no actual plot style in this case the columns do not
    correspond to specific axes. Therefore xrange, yrange, etc are ignored.

     
  • Daniel Dan K.

    Daniel Dan K. - 2025-09-19

    Hello Ethan,
    Thank you for your response. I missed the point in the documentation where the limitations of the plot style with table are clearly described.

    Now if I plot into a datablock using table mode and not using with table, all points are plotted including an additional column indicating whether they are in range or not.
    Example:

    set table $k
    plot [2:4] $data 
    unset table
    

    outputs:

    # Curve 0 of 1, 5 points
    # Curve title: "$data"
    # x y type
     1  1  o
     2  2  i
     3  4  i
     4  8  i
     5  16  o
    

    Can I somehow limit the output only to data that is in the requested range or do I have to do this by means of postprocessing, e.g., using data in the third column?

    Thanks.

    Cheers,
    Daniel

     
    • Ethan Merritt

      Ethan Merritt - 2025-09-19

      Yes. You can apply a filter operation to the data. Since filtering is done prior to plotting, any points that are filtered out will not appear in the output. See help filter if.
      In your case:

      set table $k
      plot $data using 1:2   if (2 <= column(1) && column(1) <= 4) 
      unset table
      
       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.