gnuplot legend overlaps graph

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.

Following is the command that I am using to plot the data.

> set log y
> plot "datafile1.txt" using 2:4 with lines,
  "datafile1.txt" using 2:6 with lines,
  "datafile2.txt" using 2:4 with lines,
  "datafile2.txt" using 2:6 with lines

Following is a portion of the data file 1 I am using to plot the data.

Dimension:  259 Timing: 36111 seconds,  9 seconds
Dimension:  260 Timing: 37860 seconds,  9 seconds
Dimension:  261 Timing: 39477 seconds,  6 seconds
Dimension:  262 Timing: 41215 seconds,  5 seconds
Dimension:  263 Timing: 41827 seconds,  5 seconds
Dimension:  264 Timing: 42738 seconds,  11 seconds
Dimension:  265 Timing: 42972 seconds,  14 seconds
Dimension:  266 Timing: 44138 seconds,  10 seconds
Dimension:  267 Timing: 45210 seconds,  11 seconds
Dimension:  268 Timing: 46508 seconds,  9 seconds
Dimension:  269 Timing: 51120 seconds,  15 seconds
Dimension:  270 Timing: 49352 seconds,  6 seconds
Dimension:  271 Timing: 50456 seconds,  9 seconds
Dimension:  272 Timing: 52379 seconds,  16 seconds
Dimension:  273 Timing: 52354 seconds,  16 seconds

Following is a portion of the data file 2 I am using to plot the data.

Dimension:  269 Timing: 32507 seconds,  2 seconds
Dimension:  270 Timing: 33064 seconds,  4 seconds
Dimension:  271 Timing: 33590 seconds,  6 seconds
Dimension:  272 Timing: 33703 seconds,  3 seconds
Dimension:  273 Timing: 34616 seconds,  3 seconds
Dimension:  274 Timing: 36113 seconds,  4 seconds
Dimension:  275 Timing: 36477 seconds,  4 seconds
Dimension:  276 Timing: 37000 seconds,  2 seconds
Dimension:  277 Timing: 37872 seconds,  3 seconds
Dimension:  278 Timing: 42290 seconds,  6 seconds
Dimension:  279 Timing: 39862 seconds,  7 seconds
Dimension:  280 Timing: 40184 seconds,  7 seconds
Dimension:  281 Timing: 41229 seconds,  4 seconds
Dimension:  282 Timing: 43221 seconds,  3 seconds
Dimension:  283 Timing: 42706 seconds,  7 seconds

Any help or advice on how to overcome this would be appreciated.

Answers


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",
....

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).


Need Your Help

Java naming convention for boolean variable names: writerEnabled vs writerIsEnabled

java naming-conventions boolean

Which of the following declarations conforms to Java's naming conventions?