Normally, you do not need to import the data into gnuplot to plot it.
Just use the plot command directly with the filename
plot “filename.dat” with line using 1:2
Explanation:
plot = is the command to plot
“filename.dat” = is the filename and the filetype located in the active folder
with line = how will you plot your data? This command uses a line connecting the datapoints.
Another option is “with point”. There are various options that you can choose but you will need to learn/explore it. Please google yourself for more info.
using 1:2 = this command tells gnuplot which column in your “filename.dat” to plot your data.
In this case, it is columns 1 and 2 for x and y, respectively.
If this does not work, there are several possible reasons:
- The folder location is wrong
- The filename is wrong
- The selected columns are wrong
- The datafile separator is different
- and other reasons that I do not know yet..
You can also perform mathematical operations on the data directly. For example, you want to squareroot column 2 in the data… or maybe multiply it with 1000.. or sine it.. you get the idea.
To do this, use parentheses ( ) and you can perform such operations.. For example:
using ($1):2 = the dollar sign indicates column. If you do not put $ symbol, the “1” will be the number 1 and not a constant. As you can see, there is no mathematical operation here (yet).
using ($1*2):2 = multiplies column 1 with 2.
using ($1**4):2 = column 1 to the power of 4.
using 1:(sqrt($2**2+$3**2)) = square root the sum of squared data from column 2 and 3.
You can perform all sorts of maths operation to the data..