有条件地在Gnuplot中打印多个文件

有条件地在Gnuplot中打印多个文件,gnuplot,Gnuplot,这是这个问题的一个分支,尽管有点复杂(或者看起来) 这是交易。我有两个不同的文件。一个文件具有最佳数据点,一个文件具有不可行和非最佳数据点 这些文件的格式与上一个问题中的格式相同,但我稍后将再次发布它们 我的目标是用脉冲(可能)在一个3D散点图上绘制所有东西 想象一下,我有一个约束,Xvalue>18,Yvalue65。典型的范围是X=[0:22],Y=[0:500],Z=[0:85](与上一篇文章相比有微小变化) 任何不符合此标准的点都是不可行的,必须以灰色绘制。任何符合此标准但来自非优化文

这是这个问题的一个分支,尽管有点复杂(或者看起来)

这是交易。我有两个不同的文件。一个文件具有最佳数据点,一个文件具有不可行和非最佳数据点

这些文件的格式与上一个问题中的格式相同,但我稍后将再次发布它们

我的目标是用脉冲(可能)在一个3D散点图上绘制所有东西

想象一下,我有一个约束,Xvalue>18,Yvalue<20,Zvalue>65。典型的范围是X=[0:22],Y=[0:500],Z=[0:85](与上一篇文章相比有微小变化)

任何不符合此标准的点都是不可行的,必须以灰色绘制。任何符合此标准但来自非优化文件.dat的点必须以红色绘制。最后,最优_data.dat文件中的点必须以蓝色绘制。不用说,这些文件中的要点必须是可行的

我使用了@andyras的解决方案,可以解决问题的第一部分。但当我将另一个文件合并到同一个绘图中时,所有的点都变成了灰色。我重新定义了我的调色板等,但能够得到蓝色和红色,而不是灰色和红色的不可行和非最佳点。我能够用黑色绘制出最佳的,但我不能使用任何其他颜色。有人能指导我设置这个问题的调色板吗

我用了这个:

设置调色板已定义(0 0 0 1,1 1 0 0,2 1 0 0)#(蓝色,黄色,红色)

数据文件的格式与上一个案例相同。我需要使用顺序为2:1:3的前三列作为X:Y:Z

样本数据: 最佳点:

20      10.078509647223639      50      172
46      10.395137748213685      43      18
34      10.1846571593967        33      18
74      11.054241806019         42      18
34      11.472806910917914      30      92
非最优/不可行点:

20      9.835854999471227       42      35
20      11.901179073913957      44      35
20      12.204287402540535      51      35
255     15.216006917180689      66      172
20      11.651167171495924      52      172
20      11.89284904845455       48      172

我被引导为此创建一个新问题,因为它有点不同。因此产生了分支。如果不能这样做,我深表歉意。

好的,我想我找到了一个解决办法(抱歉耽搁了)

我想这个剧本就像你描述的那样;我主要对最优与非最优等问题感到困惑。我认为您的脚本不起作用的原因是您使用了相同的比较器(isbig(x,y,z))来尝试获得三种可能的结果,但函数只定义了两种。我刚刚定义了第二个比较器用于第二个数据文件,它似乎工作正常

20      9.835854999471227       42      35
20      11.901179073913957      44      35
20      12.204287402540535      51      35
255     15.216006917180689      66      172
20      11.651167171495924      52      172
20      11.89284904845455       48      172
#!/usr/bin/env gnuplot

set terminal png
set output 'test.png'

# cutoffs for non-optimal points
bigx = 16; bigy = 400; bigz = 65
# big value to shift dummy points off of plot
shift = 1e6

# conditional for non-pareto
isbig(x,y,z) = (x > bigx || y > bigy || z > bigz) ? 1 : 0
# conditional for pareto
isbig2(x,y,z) = (x > bigx || y > bigy || z > bigz) ? 0 : 2

set palette defined (0 0.5 0.5 0.5,\
                     1 1.0 0.0 0.0,\
                     2 0.0 0.0 1.0) # (grey, red, blue)

unset colorbox

set xrange [0:20]; set yrange [0:500]; set zrange [0:100]

# plot commands for points use dummy points just to make key
# this is because there are multiple types of points coming from one file
splot 'data.dat' using 2:1:3:(isbig($2,$1,$3)) with points pt 7 palette notitle, \
      'optimal.dat' using 2:1:3:(isbig2($2,$1,$3)) with points pt 7 palette notitle, \
      '' using (shift):(1):(1) with points pt 7 lc rgb 'blue' title 'optimal non-pareto', \
      '' using (shift):(1):(1) with points pt 7 lc rgb '#888888' title 'optimal pareto', \
      '' using (shift):(1):(1) with points pt 7 lc rgb 'red' title 'non-optimal'