'Gnuplot plotting the wrong graph from given datapoints
I have a file containing some datapoints:
# energytime.dat
# X Y
64.934 1993
64.9264 0.0029
64.9022 1897
64.9296 1877
64.8698 1885
64.953 3799
I wrote the following script to plot a graph:
#!/usr/bin/gnuplot -persist
set title "Energy vs. Time for all algorithms"
set xlabel "Energy"
set ylabel "Time"
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
plot "energytime.dat" with linespoints linestyle 1
pause -1 "Hit Enter to continue"
This gives the following graph:
It is obvious that this plot is wrong. What modifications should I make to my script to get the correct graph?
Solution 1:[1]
As @theozh wrote, gnuplot simply plots the data in the order they stored in the datafile. However, you can "correct" your graph with smooth unique
plot "energytime.dat" smooth unique with linespoints linestyle 1
(assuming, that you will never have two identical x values).
NOTE
It is important, to use smooth unique before with.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

