gnuplot store one number from data file into variable

前端 未结 3 441
北恋
北恋 2020-12-01 12:51

OSX v10.6.8 and Gnuplot v4.4

I have a data file with 8 columns. I would like to take the first value from the 6th column and make it the title. Here\'s what I have

3条回答
  •  庸人自扰
    2020-12-01 13:38

    This is a very old question, but here's a nice way to get access to a single value anywhere in your data file and save it as a gnuplot-accessible variable:

    set term unknown #This terminal will not attempt to plot anything
    plot 'myfile.dat' index 0 every 1:1:0:0:0:0 u (var=$1):1
    

    The index number allows you to address a particular dataset (separated by two carriage returns), while every allows you to specify a particular line.

    The colon-separated numbers after every should be of the form 1:1::::, where the line number is the line with the the block (starting from 0), and the block number is the number of the block (separated by a single carriage return, again starting from 0). The first and second numbers say plot every 1 lines and every one data block, and the third and fourth say start from line and block . The fifth and sixth say where to stop. This allows you to select a single line anywhere in your data file.

    The last part of the plot command assigns the value in a particular column (in this case, column 1) to your variable (var). There needs to be two values to a plot command, so I chose column 1 to plot against my variable assignment statement.

提交回复
热议问题