Search code examples
gnuplotblock

plotting single (datum,column) from each block with lines in gnuplot


I have a data file containing constant-size blocks of data. In order to plot element (n,m) from each block I do

pl file u m ev ::n-1::n-1

This works fine, but the graph is displayed in point style since this is default for data. When I add "with lines" to the command above, this produces an empty graph.


Solution

  • Maybe there are shorter solutions, but the first solution which comes to my mind is to plot the data into a datablock and then plot this datablock. This will remove empty lines and hence datapoints will be connected when plotting with lines or with linespoints.

    Code:

    ### plot individual datapoints from each block with lines
    reset session
    
    $Data <<EOD
    1  11
    2  12
    3  13
    
    4  14
    5  15
    6  16
    
    7  17
    8  18
    9  19
    EOD
    
    m = 2
    n = 1
    
    set table $DataSelected
        plot $Data u m every ::n-1::n-1 w table
    unset table
    
    plot $DataSelected u 1 w linespoints pt 7
    ### end of code
    

    Result:

    enter image description here