I would like to plot a csv file with gnuplot. Instead of a line, I want to use points that are evenly distributed along the path of the curve. However, the data in the csv file is not evenly distributed, e.g. like this
x,p
0,2
1,4
1.1,4.2
1.2,4.4
2.8,7.6
2.85,7.7
4,10
It should be possible to achieve this, but how?
Here is an example graph where I plot every nth point. Because my numerical solution is so good :-) you only see one line, so I would like to have markers on the one curve. But the points should be distributed equidistantly (the current distribution is only due to the nature of the analytical solution).
In the development version of gnuplot (5.5) this can be done exactly as asked. smooth path
does what you would expect, and pn 7
tells it to place exactly 7 evenly spaced points.
$DATA << EOD
0,2
1,4
1.1,4.2
1.2,4.4
2.8,7.6
2.85,7.7
4,10
EOD
set log y
set key top left
set datafile separator comma
plot $DATA smooth path with lp pn 7 title "smooth path pn 7", \
$DATA with points pt 6 ps 2 title "original points"
The current version 5.4 does not offer smooth path
, but if your data points are sufficiently close to lying on a smooth curve one of the other smoothing options, e.g. smooth mcs
, may be acceptable.
For the record, I think this is not a good thing to do. It is dishonest to hide the actual data points while showing artificially even points instead. It misleads the viewer as to where the curve is reliable and where it may not be.