Gnuplot 设置数据标签的背景色

Gnuplot set background color of data label

我想将数据标签的背景设置为白色!所考虑的图是以下数据 (gnuDC.dat) 的数据图:

4   1570.96 1571
8   770.63  771
12  530.33  530
16  385.13  385
24  261.87  262
48  137.71  138
96  81.42   81

绘图命令为:

plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p ls 1, \
 "gnuDC.dat" using 1:2:3 with labels center offset 2.,0.7 font "Helvetica,14" tc ls 4 notitle, \
 "gnuDC.dat" using 1:3 notitle smooth csplines ls 14

这给了我:

它看起来不错,但认为当标签有白色背景时可以更好地阅读标签。有没有一种简单的方法可以一次性为所有标签添加白色背景?

这是整个打印文件:

set terminal postscript eps size 14cm,10cm enhanced color \
        font 'Helvetica,18' linewidth 2

set output 'test.eps'

# Line style for axes
set style line 80 lt 0
set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 lt 3  # dashed
set style line 81 lt rgb "#808080" lw 0.5  # grey

set grid back linestyle 81
set border 3 back linestyle 80
set xtics nomirror
set ytics nomirror

set style line 100 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5
set style line 200 lc rgb '#a2142f' lt 1 lw 2 pt 7 ps 1.5
set pointintervalbox 0

set style line 1 lc rgb '#0072bd' lt 1 lw 1 pt 9 pi -10 ps 2
set style line 2 lc rgb '#77ac30' lt 1 lw 1 pt 7 pi -10 ps 2
set style line 3 lc rgb '#d95319' lt 1 lw 1 pt 1 pi -10 ps 2

set bmargin 4
set lmargin 5
set rmargin 4

unset title
set size 1,1
#set origin 0,0.27
set xlabel "number of cores, -"
set ylabel "Computational time, s"

set key top right
set key spacing 1.5
set key width -12

set yrange [0:1710]

plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p ls 1, \
     "gnuDC.dat" using 1:2:3 with labels center offset 2.,0.7 font "Helvetica,14" tc ls 4 notitle, \
     "gnuDC.dat" using 1:3 notitle smooth csplines ls 14

对于 gnuplot 版本 5,有一个 boxed 选项可以做到这一点:为标签提供背景,如果需要,还可以提供边框。样式由 set style textbox 控制,例如

set style textbox opaque noborder
plot ... with labels boxed ...

应用于您的脚本(由于 5.0 后破折号处理方式发生了一些小的变化):

# Line style for axes

set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 dt 3  # dashed
set style line 81 lt rgb "#808080" lw 0.5  # grey

set grid back linestyle 81
set border 3 back linestyle 80
set tics nomirror

set linetype 1 lc rgb '#0072bd' pt 9 pi -10 ps 2 dt 3

set bmargin 4
set lmargin 5
set rmargin 4

set xlabel "number of cores, -"
set ylabel "Computational time, s"

set key top right
set key spacing 1.5
set key width -12
set yrange [0:1710]

set style textbox opaque noborder

plot "gnuDC.dat" using 1:2 title "DC: GNU Fortran 4.7.2 + Open MPI 1.6.3" w p lt 1, \
     "gnuDC.dat" using 1:2:3 with labels boxed center offset 2.,0.7 font "Helvetica,10" tc ls 1 notitle, \
     "gnuDC.dat" using 1:3 notitle smooth csplines lt 1

不,对于 4.6 版和更早版本,没有简单的方法来实现这一点。