Essentially, the problem that I am experiencing is that the legend overlaps the gnuplot graph that I am trying to plot as illustrated in the following diagram.
With the gnuplot version 5.2 and maybe later, you can use
set key at x, y
where x
and y
are the values for the x-axis and y-axis respectively
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).
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
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",
....