如何在gnuplot中为圆圈添加图例?

时间:2015-10-05 22:18:01

标签: gnuplot

我有一个gnuplot脚本,它绘制了这样的数字:

enter image description here

这是我的剧本:

set term pdf size 11,4.7 font "Arial,24"
set output "plot/application.pdf"


set object circle at 9,20 size 0.35 lw 4 fc rgb "red"

plot 'plot/application.csv' using 1:xtic((int($0)%4)==0?sprintf("%d", $0*10):"") title columnheader(1) pt 1 lw 1, \
'' using 2 title columnheader(2) pt 2 lw 1 ps .1 lc rgb "#4169E1", \
'' using 3 title columnheader(3) pt 3 lw 1 ps .1 lc rgb "#DAA520", \
'' using 4 title columnheader(4) pt 4 lw 1 ps .1 lc 5, \
'' using 5 title columnheader(5) pt 4 lw 1 ps .1 lc 9, \
'' using 6 title columnheader(6) pt 4 lw 1 ps .1 lc 7, \
'' using 7 title columnheader(7) pt 5 lw 1 ps .1 lc 8, \

''使用7个标题列标题(8)pt 5 lw 1 ps .1 lc 9

所以基本上我想添加一个与添加的圆相对应的图例,使它看起来像这样:

enter image description here

我尝试从set object调整到类似plot xxx with circles的内容,但语法总是不正确。

有没有人可以帮助我生成正确的传奇?非常感谢你!

我在这里上传我的数据文件。

process1, process2, process3, process4, process5, process6, process7, process8
100, 100, 100, 100, 100, 100, 100, 100
79.69 , 81.42 ,  78.13 ,  87.694 , 78.231  , 80.231  , 78.231 , 73.231
  62.53 , 73.97 ,  61.58 ,  73.539 , 71.401  , 71.401  , 78.401 ,   65.401
49.98 , 62.85 ,  50.50 ,  54.987 , 59.922  , 53.922  , 64.922 , 56.922
35.89 , 43.60 ,  40.41 ,  45.897 , 40.010  , 44.010  , 51.010 , 43.010
29.44 , 33.73 ,  30.85 ,  37.448 , 30.488  , 35.488  , 43.488 , 31.488
20.05 , 25.53 ,  33.86 ,  30.059 , 27.098  , 23.098  , 34.098 , 27.098
19.88 , 20.67 ,  26.25 ,  25.68 ,  20.45  ,  20.45  ,  27.45  , 18.45
19.01 , 20.04 ,  24.25 ,  20.01 ,  19.358 ,  19.358 ,  25.358 , 15.358
21.88 , 18.61 ,  22.06 ,  23.88 ,  20.054 ,  20.054 ,  20.054 , 15.054
21.18 , 18.33 ,  23.67 ,  22.91 ,  19.022 ,  19.022 ,  19.022 , 12.022
17.01 , 20.04 ,  24.25 ,  18.01 ,  23.358 ,  14.358 ,  13.358 , 10.358
19.88 , 14.61 ,  20.06 ,  16.88 ,  21.054 ,  15.054 ,  10.054 , 5.054
16.18 , 12.33 ,  23.67 ,  15.91 ,  16.022 ,  12.022 ,  9.022 , 9.022

和我的完整脚本:

set term pdf size 11,4.7 font "Arial,24"
set output "plot/application.pdf"
set datafile separator ","
set offset 0, 0, 0, 0
set multiplot layout 1,1
set size ratio 0.5
set xtics norangelimit
set ytics nomirror
set termoption dashed
set yrange [0:110]
set style data linespoints
set key vertical maxrows 5
 set key top right
set key vertical maxrows 5

set object circle at 9,20 size 0.35 lw 4 fc rgb "red"

plot 'plot/application.csv' using 1:xtic((int($0)%4)==0?sprintf("%d", $0*10):"") title columnheader(1) pt 1 lw 1, \
'' using 2 title columnheader(2) pt 2 lw 1 ps .1 lc rgb "#4169E1", \
'' using 3 title columnheader(3) pt 3 lw 1 ps .1 lc rgb "#DAA520", \
'' using 4 title columnheader(4) pt 4 lw 1 ps .1 lc 5, \
'' using 5 title columnheader(5) pt 4 lw 1 ps .1 lc 9, \
'' using 6 title columnheader(6) pt 4 lw 1 ps .1 lc 7, \
'' using 7 title columnheader(7) pt 5 lw 1 ps .1 lc 8, \
'' using 8 title columnheader(8) pt 5 lw 1 ps .1 lc 9, \

1 个答案:

答案 0 :(得分:1)

为了绘制单个点with circles和图例,您必须拥有一个包含此单点的数据源。最常用的方法是使用内联数据,即来自'-'

的图
set datafile separator ","
plot 'plot/application.csv' using 1:xtic((int($0)%4)==0?sprintf("%d", $0*10):"") title columnheader(1) pt 1 lw 1, \
'' using 2 title columnheader(2) pt 2 lw 1 ps .1 lc rgb "#4169E1", \
'' using 3 title columnheader(3) pt 3 lw 1 ps .1 lc rgb "#DAA520", \
'' using 4 title columnheader(4) pt 4 lw 1 ps .1 lc 5, \
'' using 5 title columnheader(5) pt 4 lw 1 ps .1 lc 9, \
'' using 6 title columnheader(6) pt 4 lw 1 ps .1 lc 7, \
'' using 7 title columnheader(7) pt 5 lw 1 ps .1 lc 8, \
'' using 7 title columnheader(8) pt 5 lw 1 ps .1 lc 9, \
'' using 8 title columnheader(8) pt 5 lw 1 ps .1 lc 9
'-' using 1:2 with circles lw 4 lc rgb 'red' title 'best choice'
9, 20
e

使用gnuplot 5,你还可以定义一个数据块并从中绘图:

$data <<EOD
9,20
EOD
set datafile separator ","
plot $data using 1:2 lw 4 lc rgb 'red' title 'best choice'

后一种解决方案也可以与交互式终端一起使用,您可以在其中进行缩放,滚动重绘。