代码之家  ›  专栏  ›  技术社区  ›  Gert Gottschalk

Gnuplot曲线之间的透明着色区域

  •  2
  • Gert Gottschalk  · 技术社区  · 7 年前

    我有一个包含平均值和标准偏差列的数据集。我可以绘制平均值+西格玛和平均值-西格玛曲线高于和低于平均值。现在我想在+-σ之间加上阴影,但仍然可以看到平均曲线。我尝试了下面的透明设置,但仍然没有成功。

     set style fill transparent solid 0.5 noborder
     plot 'inter.dat' using 1:2 with linespoints lc "black", \
          'inter.dat' using 1:($2-$3)  with linespoints lc "blue", \
          'inter.dat' using 1:($2+$3)  with linespoints lc "blue", \
          'inter.dat' using 1:($2-$3):($2+$3) with filledcurves lc "skyblue" fs solid 0.5
    

    样本数据:

     0.490  -5.809   +2.203 
     0.500  -1.293   +1.370 
     0.520  -1.026   +0.979 
     0.530  -0.877   +0.961 
     0.540  -0.656   +0.937 
     0.550  -0.878   +0.923 
     0.560  -0.649   +0.876 
     0.570  -0.729   +0.859 
     0.580  -0.370   +0.771 
     0.590  -0.421   +0.710 
    

    非常感谢您的反馈。

    1 回复  |  直到 7 年前
        1
  •  4
  •   user8153    7 年前

    您指定 transparent 在第一个fillstyle声明中,但实际上会在plot命令中重写该声明。你可以任意选择

    set style fill transparent solid 0.5 noborder
    plot 'inter.dat' using 1:2 with linespoints lc "black", \
         'inter.dat' using 1:($2-$3)  with linespoints lc "blue", \
         'inter.dat' using 1:($2+$3)  with linespoints lc "blue", \
         'inter.dat' using 1:($2-$3):($2+$3) with filledcurves lc "skyblue" 
    

    plot 'inter.dat' using 1:2 with linespoints lc "black", \
         'inter.dat' using 1:($2-$3)  with linespoints lc "blue", \
         'inter.dat' using 1:($2+$3)  with linespoints lc "blue", \
         'inter.dat' using 1:($2-$3):($2+$3) with filledcurves lc "skyblue" fs transparent solid 0.5
    

    得到

    enter image description here

    此外,请记住,并非所有终端都支持透明度;上面的图像是使用 pngcairo .