在gnuplot中使用“ front”键交换对象的层

时间:2019-04-18 13:26:51

标签: gnuplot

我避免了自己冗长而无聊的代码,只专注于重要的事情。我用两条线生产

set arrow from xarr_1, yarr_1 to xarr_2, yarr_2 nohead lc 'white' lw 2 front
set object circle at xarr_2, yarr_2 size screen 0.01 fc rgb "black" fillstyle solid 1.0 front 

下图中的黑色圆圈和白色区域(一堆箭头)(仅一个就足够了) Image representing two distribution and their mean positions. The white zone is the zone covered by the white during the evolution of our distributions and the black is the current mean position. 由于在两个对象上:箭头和圆圈,我使用键front将其放在plot命令的前面,所以我现在希望黑色对象在箭头“白色区域”的前面

我该怎么做?

PS:无论是否交换命令,此简化代码都会出现相同的问题

reset session 
reset
PI = 4.*atan(1.)
set xrange [-PI:PI]
set arrow from -0.1, 0.1 to 0.1, -0.1 lc 'black' lw 2 front 
set object circle at 0, 0 radius 0.1 fillstyle solid 1.0 fc rgb 'red' front 
plot  sin(x) w l 
pause -1 

1 个答案:

答案 0 :(得分:2)

如果您查看gnuplot手册(help layers),则按照特定的顺序绘制对象:在对象(矩形,圆形,椭圆形,多边形)前面的标签前面的箭头。据我了解,除非使用多重绘图,否则您不能在箭头前面画一个圆。如果我正确理解了您的问题,则希望在箭头前面放置一个圆圈。因此,您可能必须使用多重绘图。

类似这样的东西:

### plot circle in front of an arrow
reset session

set obj 999 rect from graph 0, graph 0 to graph 1, graph 1 fc rgb "black" behind
set print $Data   # create some random data
do for [i=1:1000] { print sprintf("%g %g", invnorm(rand(0)), invnorm(rand(0)))}
set print

set xrange[-3:3]
set yrange[-3:3]
set multiplot
    set arrow 1 from -1,1 to 1,-1 lc 'white' lw 3
    plot $Data u 1:2 w p pt 7 ps 1 lc rgb "red"

    set object 1 circle at 0,0 radius 0.5 fillstyle solid 1.0 fc rgb 'blue' front
    unset obj 999 # don't use the black background again
    plot -10 not  # plot some dummy out of range
unset multiplot
### end of code

给出如下信息:

enter image description here