This would be my suggestion on the simplfied assumption that there are only 3 colors (red, green, blue) depending only on x
and y
and constant colors within 60 degree sectors. Let me know if this assumption is not correct.
Script: (tested with gnuplot 5.0.0 and 5.4.1)
### variable color contour line
reset session
FILE = "SO73015796.dat"
set contour
set cntrparam levels discrete 7.245
rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)
set table $Contour
splot FILE u 1:2:3
unset table
set xyplane relative 0
unset contour
unset colorbox
set angle degrees
myColor(x,y) = (a=atan2(y,x), abs(sin(a))<sin(30) ? 0x00ff00 : \
abs(sin(a-60))<sin(30) ? 0xff0000 : 0x0000ff)
set key noautotitle
splot FILE u 1:2:3:(rgb($4,$5,$6)) w pm3d lc rgb var, \
$Contour u 1:2:(6.5):(myColor($1,$2)) index 1 w l lw 2 lc rgb var
### end of script
Result:

Addition:
The following is a solution which doesn't make simplified assumptions, but takes the color from the original data. Well, a bit slow and inefficient. Maybe somebody has ideas to speed this up (maybe with specialized external tools).
- plot the contour lines into a new datablock
- find the closest point (in x,y) from 3D data and take its color (in principle, you could also interpolate the color between closest points)
In the example below you have 2 contour lines and about 700 contour points and about 15000 3D-points in your file. Hence, you need to read the 3D-file about 700 times from disk. Therefore, I thought it might be faster if you first load the file 1:1 into a datablock into memory,
but I am not sure if it is really faster. On my old laptop the creation of the graph takes about 1-2 minutes.
Script: (works for gnuplot>=5.2.0)
### variable color contour line
reset session
FILE = "SO73015796.dat"
FileToDatablock(f,d) = GPVAL_SYSNAME[1:7] eq "Windows" ? \
sprintf('< echo %s ^<^<EOD & type "%s"',d,f) : \
sprintf('< echo "\%s <<EOD" & cat "%s"',d,f) # Linux/MacOS
load FileToDatablock(FILE,'$Data')
set contour
set cntrparam levels discrete 7.25, 7.35
rgb(r,g,b) = int(r)*0x10000 + int(g)*0x100 + int(b)
# plot grid and contour data into datablock
set table $Temp
splot $Data u 1:2:3
unset table
unset contour
# get only contour lines into a new datablock
stats $Temp u 0 nooutput # get number of blocks
N = STATS_blocks
set table $CONTOURS
splot $Temp u 1:2:3 index 1:N-1 # all blocks except first (index 0-based) into datablock
unset table
# loop all contour points and take the color from closest 3D point
Dist(x0,y0,x1,y1) = sqrt((x1-x0)**2 + (y1-y0)**2) # distance between to points
set print $ColoredContours
do for [i=1:|$CONTOURS|] {
if (strlen($CONTOURS[i])==0 || $CONTOURS[i][1:1] eq '#') {
print $CONTOURS[i]
}
else {
x0 = real(word($CONTOURS[i],1))
y0 = real(word($CONTOURS[i],2))
dmin = NaN
stats $Data u (d=Dist(x0,y0,$1,$2),d<dmin || dmin!=dmin ? \
(dmin=d, color=rgb($4,$5,$6)) : 0) nooutput
print sprintf("%g %g 0x%06x", x0, y0, color)
}
}
set print
set xyplane relative 0
unset colorbox
set grid x,y
set key noautotitle
set zrange [zMin=6.0:]
splot $Data u 1:2:3:(rgb($4,$5,$6)) index 0 w pm3d lc rgb var, \
$ColoredContours u 1:2:(zMin):3 w l lc rgb var
### end of script
Result:
