gnuplot:后退箭头样式与多图不一致

问题描述 投票:0回答:1

我尝试使用 gnuplot 6.0 patchlevel 0(由 MS Windows 10 下的 Chocolatey 提供)在一系列绘图后面绘制一些箭头,但结果不一致且令人困惑。

这里是一些重现该行为的示例数据,另存为

question-data.csv
:

X,Y,Group
0,3,A
1,7,A
2,3,A
3,7,B
4,3,B
5,7,B
6,3,C
7,7,C
8,3,C

这个脚本使用

plot
来绘制图表,并完成我的意思。

dataFile = "question-data.csv"
set datafile separator ','
set yrange [0:10]

# Filter by group.
yornothing(l,lc,y) = ((l eq lc)?y:NaN)

# Has to be done before plot!
set arrow 1 from graph 0, first 4 to graph 1, first 4 nohead back lc rgb "#C0C000" lw 2
set arrow 2 from graph 0, first 5 to graph 1, first 5 nohead back lc rgb "#00FF00" lw 2
set arrow 3 from graph 0, first 6 to graph 1, first 6 nohead back lc rgb "#C0C000" lw 2

plot dataFile every ::1 using 1:(yornothing(strcol(3),"A",$2)) with filledcurves above lc rgb "#0000FF" notitle, \
    dataFile every ::1 using 1:(yornothing(strcol(3),"B",$2)) with filledcurves above lc rgb "#FFA500" notitle, \
    dataFile every ::1 using 1:(yornothing(strcol(3),"C",$2)) with filledcurves above lc rgb "#0000FF" notitle

result of script using plot

花了一段时间才意识到必须在任何绘图之前绘制箭头;直到那时,他们默默地失败了。我无法找到记录在哪里。

这是一个尝试使用

multiplot

 绘制图形的脚本,但箭头最终出现在前两个图的 
front 中,并且仅最终出现在第三个图的后面:

dataFile = "question-data.csv" set datafile separator ',' set yrange [0:10] # Filter by group. yornothing(l,lc,y) = ((l eq lc)?y:NaN) # Has to be done before plot! set arrow 1 from graph 0, first 4 to graph 1, first 4 nohead back lc rgb "#C0C000" lw 2 set arrow 2 from graph 0, first 5 to graph 1, first 5 nohead back lc rgb "#00FF00" lw 2 set arrow 3 from graph 0, first 6 to graph 1, first 6 nohead back lc rgb "#C0C000" lw 2 set multiplot plot dataFile every ::1 using 1:(yornothing(strcol(3),"A",$2)) with filledcurves above lc rgb "#0000FF" notitle plot dataFile every ::1 using 1:(yornothing(strcol(3),"B",$2)) with filledcurves above lc rgb "#FFA500" notitle plot dataFile every ::1 using 1:(yornothing(strcol(3),"C",$2)) with filledcurves above lc rgb "#0000FF" notitle unset multiplot

result of script using multiplot

如果我向

multiplot

添加虚假的第四个图,箭头现在会神秘地绘制在
所有图表的前面:

dataFile = "question-data.csv" set datafile separator ',' set yrange [0:10] # Filter by group. yornothing(l,lc,y) = ((l eq lc)?y:NaN) # Has to be done before plot! set arrow 1 from graph 0, first 4 to graph 1, first 4 nohead back lc rgb "#C0C000" lw 2 set arrow 2 from graph 0, first 5 to graph 1, first 5 nohead back lc rgb "#00FF00" lw 2 set arrow 3 from graph 0, first 6 to graph 1, first 6 nohead back lc rgb "#C0C000" lw 2 set multiplot plot dataFile every ::1 using 1:(yornothing(strcol(3),"A",$2)) with filledcurves above lc rgb "#0000FF" notitle plot dataFile every ::1 using 1:(yornothing(strcol(3),"B",$2)) with filledcurves above lc rgb "#FFA500" notitle plot dataFile every ::1 using 1:(yornothing(strcol(3),"C",$2)) with filledcurves above lc rgb "#0000FF" notitle # Empty plot, to change nature of problem plot dataFile every ::1 using 1:(yornothing(strcol(3),"D",$2)) with filledcurves above lc rgb "#0000FF" notitle unset multiplot

result of hacked script using multiplot

这是一个错误,还是我对多重图的误解? gnuplot 相当复杂,我只触及了它的表面。

graph gnuplot histogram
1个回答
0
投票
我认为这是对多重情节的误解。 “set multiplot”允许您发出多个绘图命令,这些命令绘制在同一画布上,而无需擦除绘图之间的画布。 多图序列中的每个

plot

 命令均使用该 
plot
 命令时有效的所有设置完整绘制,包括定义的所有对象、箭头、标签等。  因此,对于 
plot
 内的三个 
multiplot
 命令中的每一个,都会重新绘制三个箭头,并且每次绘制它们时,它们都必须绘制在画布的先前内容之上(因为它不会被删除)介于两者之间)。

至于您的第一句话“

必须在任何绘图之前绘制箭头”,这可能表明存在单独的误解。 set arrow

 命令本身并不绘制箭头。  它仅定义一个箭头,该箭头将作为所有后续 
plot
 命令的一部分绘制。这与定义将包含在所有后续绘图中的附加元素的命令 
set label
set object
 等相同。

还有一件事可能相关。 定义箭头时,您可以指定它们是出现在

plot with filledcurves

 绘制的曲线后面还是前面。

gnuplot> help layer A gnuplot plot is built up by drawing its various components in a fixed order. This order can be modified by assigning some components to a specific layer using the keywords `behind`, `back`, or `front`. For example, to replace the background color of the plot area you could define a colored rectangle with the attribute `behind`. set object 1 rectangle from graph 0,0 to graph 1,1 fc rgb "gray" behind The order of drawing is behind back the plot itself the plot legend (`key`) front Within each layer elements are drawn in the order grid, axis, and border elements pixmaps in numerical order objects (rectangles, circles, ellipses, polygons) in numerical order labels in numerical order arrows in numerical order In the case of multiple plots on a single page (multiplot mode) this order applies separately to each component plot, not to the multiplot as a whole.
    
© www.soinside.com 2019 - 2024. All rights reserved.