gnuplot图例重叠图

时间:2012-08-31 02:10:38

标签: graph gnuplot

基本上,我遇到的问题是图例重叠了我试图绘制的gnuplot图,如下图所示。

Timings

以下是我用来绘制数据的命令。

> 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

以下是我用来绘制数据的数据文件1的一部分。

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

以下是我用来绘制数据的数据文件2的一部分。

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

如何克服这一点的任何帮助或建议将不胜感激。

4 个答案:

答案 0 :(得分:41)

如果您想完全关闭它:

gnuplot> set nokey

如果要移动图例,可以使用

执行此操作
gnuplot> set key left top

将其移至左上角。如果要在图例中为线条指定更有意义的名称,请在生成图表时使用title关键字:

gnuplot> plot "datafile1.txt" using 2:4 with lines title "data",
....

答案 1 :(得分:18)

您可以将图例移到绘图区域之外,然后它们肯定不会重叠:

gnuplot> set key outside

请点击此处查看有关图例或按键位置的更多选项: http://gnuplot.sourceforge.net/docs_4.2/node192.html

答案 2 :(得分:6)

您可以通过提供一组坐标来控制键的位置:

set key at 25., 5000.

这些值对应于数据坐标系。或者,您可以指定 graph 坐标:

set key at graph 0.1, 0.9

(靠近左上角)。

答案 3 :(得分:4)

对于gnuplot 5.2和更高版本,您可以使用

set key at x, y

其中xy分别是x轴和y轴的值