使用GNUplot设置轮廓标签,网格和颜色图插值吗?

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

因此,我一直在尝试创建一个热图,其轮廓图从2d数组叠加在顶部。我大部分时候都取得了成功,但是我陷入了困境。

问题1:我无法在每个轮廓上显示标签。我在情节之前设置了这些命令:

                    set cntrlabel start 1 interval 1

此命令应在标签的第一条轮廓线上以1的间隔放置标签(在每个轮廓上放置标签)。但是什么都没有出现。

问题2 :(已解决)我无法正确显示网格。如果我删除了绘制颜色图的plot命令的一部分,则网格将出现在仅轮廓版本上。同时绘制两个图时,不会出现网格。为什么会这样?

问题3:我试图使用pm3d插值色彩图。正如您从我的输出中看到的,颜色图非常“粗糙”。我已经在一个类似的例子中用这些命令成功地尝试过。

设置pm3d地图

设置pm3d内插4,4

然而,在本示例中使用GNUplot时,GNUplot创建了带有空文件的数据文件test.dat,并且未创建颜色图。 GNUplot创建此错误消息:

第0行:警告:正在跳过没有有效点的数据文件

我使用的命令[pm3d命令将导致绘图错误]:

                    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)

任何帮助将不胜感激。

gnuplot heatmap contour
1个回答
0
投票

1)在版本5中更改了标注轮廓的机制。它现在需要一个单独的绘图命令with labels,在set contour生效时发出。

2)使用set grid front确保将其绘制在绘图元素的顶部

3)不推荐使用set pm3d map。我不确定它曾经做什么。无论如何都是没有必要的。 set pm3d interpolate x,x对我有用。

修订后的脚本和下面的输出

# 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

© www.soinside.com 2019 - 2024. All rights reserved.