Gnuplot: contour and heatmap from two different files in the same spot

I am trying to plot two 2D scalars, one as a heatmap and one as a superimposed contour using the following code:

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table cont2.dat
splot 'vr245.gnu'
unset table
reset
set xrange [1:215]
set yrange [0:3.1415925025940E+00]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10
splot 'f_aveFe_245.gnu' u 1:2:3 with pm3d, "cont2.dat" u 1:2:3 w l

      

Gnuplot output The result produced by gnuplot

As you can see, the outline has artifacts on the left. How can I fix this problem? Thank!

Input files are here.

+3


source to share


2 answers


This is actually quite interesting. It seems that the problem occurs for a specific contour corresponding to the level 1.25

. I think I have isolated the problem as follows.

Suppose we have a simple data file like

215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 

215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

      

now the gnuplot command

unset key
set view map

set xr [212:215.5]
set yr [0:3]

set xtics nomirror
set ytics nomirror

splot \
    'file.dat' w lp, \
    '' u 1:2:3:(sprintf("%d", $0)) w labels offset char 0, char -0.5

      

products enter image description here

interestingly, points 1 and 4 are also connected. If the data file is changed as

215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 
#
215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

      

Gnuplot only connects points 2 and 3 as expected: enter image description here



Which seems to help here duplicate an empty line, i.e. this file

215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 


215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

      

gives truly disconnected components: enter image description here

To apply this in your script, you can call, for example, gawk

and just duplicate all blank lines in the file with the contours calculated:

set terminal pngcairo
set output 'fig.png'

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table 'cont2.dat'
splot 'vr245.gnu'
unset table
reset

set xrange [1:215]
set yrange [0:pi]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10
splot \
    'f_aveFe_245.gnu' u 1:2:3 with pm3d, \
    '<gawk "NF==0{print;} {print;}" cont2.dat' u 1:2:3 w l

      

what gives enter image description here

Alternatively, you can fix this by using plot

to draw paths instead of splot

:

set terminal pngcairo
set output 'fig.png'

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table 'cont2.dat'
splot 'vr245.gnu'
unset table
reset

set xrange [1:215]
set yrange [0:pi]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10

set multiplot

set tmargin at screen 0.9
set lmargin at screen 0.1
set rmargin at screen 0.8
set bmargin at screen 0.1

splot \
    'f_aveFe_245.gnu' u 1:2:3 with pm3d

unset xtics
unset ytics
unset border
unset key
plot \
    'cont2.dat' w l

      

+1


source


You can selectively turn on or off the contour and surface display for individual parcels in one splot. Determine how pm3d

and contours

in script, disable the contours of the surface for the first and for the

reset
set contour base
set cntrparam levels incremental 0,0.25,1.25
set cntrlabel onecolor
set autoscale xfix
set autoscale yfix
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10
splot 'f_aveFe_245.gnu' u 1:2:3 with pm3d nocontour, \
    'vr245.gnu' u 1:2:3 w l lc rgb "black" nosurface

      



enter image description here

+1


source







All Articles