Search code examples
gnuplot

GNUplot doesn't print lines


I'm having this script to plot some data in Gnuplot. Unfortunately, my plot doesn't print the lines, only the dots.

What have I done wrong?

#!/usr/bin/gnuplot
reset
set terminal png
set output 'picture.png'
set xlabel "n"

set ylabel "time (s)"
set yrange [0:2]

set title "title"
set key reverse Left outside
set grid
set style data linespoints

plot "bla.txt" using 1:2 title "bla" with linespoints ls 1

Solution

  • Most probably, your data file contains empty lines between successive data entries.

    A data file with

    1 2
    
    2 4
    
    5 6
    

    shows only three points when plotted with

    plot 'data.txt' using 1:2 with linespoints
    

    whereas a data file

    1 2
    3 4
    5 6
    

    also shows connecting lines.

    That is simply how gnuplot handles its data files.