Search code examples
gnuplot

Gnuplot: Points plot not precisely reflecting CSV input data


I'm plotting a CSV file and am wondering why the resulting plot does not represent the input data.

This is my CSV file (horizontal_line.csv):

0,1.0
1,1.0
2,1.0
3,1.0
4,1.0

Gnuplot script:

set datafile separator ","
set pointsize 5
plot 'horizontal_line.csv' with points

Screenshot of the resulting plot (red arrow added by me):

enter image description here

I don't understand why at x = 3.81 y jumps to 1.009. Shouldn't y be 1.0 across the whole plot?

I'm on MacOS Intel Sonoma 14.5, Gnuplot "Version 6.0 patchlevel 1 last modified 2024-05-13"


Solution

  • Your are mistaking the sample point in the plot legend ("key") for a data point. You may want to turn off the key unset key or move it outside the plot set key outside, or put a box around it set key opaque box.