1
votes

So I've been trying to create a heatmap with contour map overlayed on top from a 2d array. I've been mostly successful, but I am stuck.

Issue 1: I cannot get labels to show up on each contour. I set these commands before the plot:

                    set cntrlabel start 1 interval 1

This command should put labels on the first contour line with an interval of 1 (put labels on every contour). Yet nothing shows up.

Issue 2: (SOLVED) I cannot get the grid to show properly. If I remove the part of the plot command that plots the colormap, the grid appears on the contour only version. When both plots are plotted the grid does not appear. Why does this happen?

Issue 3: Im trying to use pm3d to interpolate colormap. As you can see from my output the colormap is very 'rough'. I've tried it on a similar example with these commands with success.

set pm3d map

set pm3d interpolate 4,4

Yet when I use it in this example GNUplot creates the data file test.dat with an empty file, and the colormap isnt created. GNUplot creates this error message:

line 0: warning: Skipping data file with no valid points

The commands I used [the pm3d commands will cause an plotting errors]:

                    cd '<Your Directory>'

                    set terminal png size 1920,1080 
                    set output 'testplot.png'
                    set xrange [0:20]
                    set yrange [0:25]
                    set pm3d map 
                    set pm3d interpolate 4,4
                    set table 'test.dat'
                    splot 'TestData.txt' matrix
                    unset table

                    set contour base
                    set cntrparam level incremental 0, 0.1, 1
                    unset surface
                    set table 'cont.dat'
                    splot 'TestData.txt' matrix
                    unset table

                    reset
                    set xrange [0:20]
                    set yrange [0:25]
                    unset key
                    
                    set cbtics 0, 0.1, 1.0
                    set cblabel 'Normalized Power Density Relative to SC6 Limit'
                    set cbrange [0:1]
                    set cntrparam level incremental 0, 0.1, 1
                    set cntrlabel start 1 interval 1
                    set grid
                    p 'test.dat' with image, 'cont.dat' w l lt - 1 lw 1.5 

Link to TestData.txt which is arbitrary 2d array

My current plot output

example desired output plot (with smooth heatmap, contour labels, but no grid)

Any help would be greatly appreciated.

1

1 Answers

0
votes

1) The mechanism for labeling contours changed in version 5. It now requires a separate plot command with labels, issued while set contour is in effect.

2) Use set grid front to make sure it is drawn on top of the plot elements

3) set pm3d map is deprecated. I'm not sure any more what it used to do. Anyhow it is unnecessary. set pm3d interpolate x,x does work for me.

Revised script and output below

# Require "with pm3d"
set pm3d explicit

# Smooth pm3d colors
set pm3d interpolate 3,3

set contour
set cntrparam level incremental 0, 0.1, 1

set view map
unset key
unset border

set xrange [*:*] noextend
set yrange [*:*] noextend

# Plot elements will be rendered in the order given.
# The grid will go in front of that.
set grid x y lc "white" front

# Note that grid lines only appear at axis tic locations.
# But black tics would hide the white grid lines, so scale them to 0 length
set tics scale 0

splot 'TestData.txt' matrix using 1:2:3 with pm3d, \
      '' matrix using 1:2:3 with lines lw 4 nosurface, \
      '' matrix using 1:2:3 with labels textcolor "white"

enter image description here