gnuplot legend overlaps graph
You could move the legend outside the plotting area, then they definitely wouldn't overlap:
gnuplot> set key outside
See here for many more options regarding the placement of the legend or key: http://gnuplot.sourceforge.net/docs_4.2/node192.html
You can control location of the key by providing a set of coordinates:
set key at 25., 5000.
These values correspond to the data coordinate system. Alternatively, you can specify graph coordinates:
set key at graph 0.1, 0.9
(close to top-left position).
If you want to turn it off altogether:
gnuplot> set nokey
If you want to move the legend, you can do this with
gnuplot> set key left top
to move it to the top left. If you want to give the lines more meaningful names in the legend, use the title
keyword when generating the plot:
gnuplot> plot "datafile1.txt" using 2:4 with lines title "data",
....