gnuplot legend overlaps graph

Bill picture Bill · Aug 31, 2012 · Viewed 56k times · Source

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.

Timings

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.

Answer

John Lyon picture John Lyon · Aug 31, 2012

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