Search code examples
gnuplot

gnuplot: transform axis of matrix plot with "every"


I have a problem with plotting matrices with gnuplot. I am plotting one row of matrix with every option like that

plot inputfile matrix every 1:1:(4+N*M+1):100:(4+N*(M+1)):100 with linespoint

where 100 is number of row. It gave me that nearly good result:

enter image description here

I would like to get xrange from 0 to 360, but when I use something like that

plot inputfile matrix using ($1*11.25):2 every 1:1:(4+N*M+1):100:(4+N*(M+1)):100 with linespoint

it doesen't work: wrong result

enter image description here

What can I do with it?


Solution

  • You don't provide data, so I create some for the following example. As I understand you want to plot a certain row of a matrix and adjust the x-range. Check help matrix every.

    For example, in plot FILE u 1:2:3 matrix, 1 is the column, 2 the row and 3 is the (z)-value. And in plot FILE u 1:3 matrix every ::c:r:c:r, c is the column and r is the row (counting starts from 0). So the example below plots the 4th row and the x-range is adjusted from 0 to 360.

    Code:

    ### plotting a certain row while adjusting the x-range
    reset session
    
    $Data <<EOD
    1  2  3  4  5  6  7
    2  3  4  5  6  7  8
    3  4  5  6  7  8  9
    4  5  6  7  8  9 10
    5  6  7  8  9 10 11
    EOD
    
    set key top left
    plot $Data u ($1*60):3 matrix every :::3::3 w lp pt 7
    ### end of code
    

    Result:

    enter image description here