Reputation: 4642
I'm using gnuplot to plot some data in terminal, but, I can't understand what it is I'm actually plotting..
The data that I am plotting is as follows:
0 0
0 0
0 0
0 0
0 0
0 0
0 0
-4.30073 11.0396
0.597324 0.717791
0.994737 0.0914964
0.461595 -0.0463647
0.823025 -0.028436
0.175018 -0.325786
-0.162711 -0.095196
0.162538 -0.0879469
-0.207604 -0.0375564
-0.428694 0.406283
-0.509088 -0.863523
-1.98853 -0.834989
-0.81263 -0.44062
And the result is as follows:
Is gnuplot therefore just plotting the first columns of data, or performing a calculation on the data in order to plot?
The command that I'm using is as follows:
plot './data.txt' using 2 with lines
Any help would be greatly appreciated
Upvotes: 1
Views: 137
Reputation:
If there is only one data column given, gnuplot takes that as the y data. The x data are just the indices, equivalent to the row number of your input file. (It appears you set a lower x limit, because data at x=1 and x=2 aren't plotted.)
Since you specified using 2
, the first data column is completely ignored, and only the second column used, with the indices as the x values.
For reference, the documentation says "Only one column (the y value) need be provided. If x is omitted, gnuplot provides integer values starting at 0. ".
Upvotes: 1
Reputation: 342
It's just plotting second column of your datafile. (zeroes and after them goes spike to 11, gnuplot starts indexing from 1). For plotting just first column you can use:
plot './data.txt' using 1 with lines
Or if you want to plot XY graph just type one of following examples:
#simplest case, uses first column for X axis and second for Y
plot './data.txt' with lines
#Same as previous, but can be helpful if there more than two columns in datafile
plot './data.txt' using 1:2 with lines
#Uses second column for X and first for Y
plot './data.txt' using 2:1 with lines
Hope this will answer your question.
Upvotes: 3