Colors gnuplot等高线颜色:设置样式线和设置线型无效
我正在绘制上一个Stackoverflow问题中描述的数据: 大多数情况下,它对我来说效果不错,我只关注一些小细节。其中之一是如何控制轮廓线的颜色和线宽。网上有很多帖子都是关于使用Colors gnuplot等高线颜色:设置样式线和设置线型无效,colors,gnuplot,contour,Colors,Gnuplot,Contour,我正在绘制上一个Stackoverflow问题中描述的数据: 大多数情况下,它对我来说效果不错,我只关注一些小细节。其中之一是如何控制轮廓线的颜色和线宽。网上有很多帖子都是关于使用set style increment user,然后通过set style line 1 lc rgb“blue”lw 2等定义用户风格。理论上,这是为了迫使splot使用新定义的样式绘制线条。我试过了,但没用。此外,当我通过gnuplot安装转到帮助页面时,我发现我的版本(版本4.7 patchlevel 0上次修
set style increment user
,然后通过set style line 1 lc rgb“blue”lw 2
等定义用户风格。理论上,这是为了迫使splot使用新定义的样式绘制线条。我试过了,但没用。此外,当我通过gnuplot安装转到帮助页面时,我发现我的版本(版本4.7 patchlevel 0上次修改时间2013-07-25)不推荐使用此用法。建议改用set linetype,这将永久更改当前gnuplot调用的gnuplot线型的特征。终止并重新启动gnuplot将恢复默认线型特征
接下来,我重新启动gnuplot,重新生成绘图,而不重新定义等高线的任何线型或类型。当我查看绘图时,我可以看到线条颜色从青色开始,然后是紫色,然后是蓝色(例如,像线条类型5、4、3或14、13、12等)。线条类型似乎正在通过可用的样式向后移动。好吧,我想,我可以改变这些,过着奇怪的生活。但是,在发出多个“设置线型”命令,将所有这些线型更改为明显不同的线型之后(我通过运行test
命令进行了验证,绘图上的等高线仍然具有与以前相同的颜色和线宽。我似乎无法确定等高线使用的线型,因此无法更改相应的线型
也许这种奇怪的行为是由于等高线的类型为set cntrparam levels increment-6,-6,-24
,负值和/或负向增量导致了一些不可预测的行为
我想知道如何知道此图中等高线将使用何种线型,以及如果用于构建曲面图的线数发生变化,该线型是否会发生变化。例如,下面显示的图使用13条“线”要使用set pm3d map
生成曲面,请假设N=13条线-第一条等高线线型是否遵循规则?例如,我是否始终确保等高线样式将从N=14开始?我想知道当“线”的数量在我的输入数据将有所不同
底线是,我需要对每个等高线级别使用的等高线应用特定样式。我希望在输入数据更改时对每个级别始终使用相同的样式。绘图将始终使用相同的等高线级别集:-6、-12、-18和-24。绘图数据将始终具有最大“z”坐标约为0,并从此处减小
Gnuplot命令如下所示。可在此处下载此绘图的数据集:
没有控制等高线的绘图如下所示。我需要能够指定等高线的线颜色和宽度。如何
以下是如何更改等高线的线属性。我无法解释为什么会这样,我只是通过测试发现了。不幸的是,没有关于这些细节的文档 行为如下(使用4.6.3.和4.7(2013-07-25和2013-09-09)测试),均显示出相同的行为: 默认设置
splot
指定linetype
,则曲面本身将使用lt 1
。在这种情况下,使用lt 3
绘制第一个轮廓。是的,与指定的增量相比,编号是向后的。但是可以使用set cntrparam levels increment-6,-6,-18
或s将其反转et cntrparam水平增量-18,6,-6
linewidth
相同,也等于用于打印命令的linewidth
,要更改它,请使用例如splot'new\u test.dat'lw 3
线型
,其索引比打印命令使用的索引高一倍线型。如果未定义此样式,等高线将返回到使用线型
linewidth
取自第一个linestyle
,忽略以下ls
中的所有lw
设置线型
,其索引比打印命令使用的索引高一倍线型,以及曲面使用的第一个线型。否则将使用默认设置
lw
与linestyle
相同reset
set terminal pngcairo size 800,800
set output '3d-polar.png'
set lmargin at screen 0.05
set rmargin at screen 0.85
set bmargin at screen 0.1
set tmargin at screen 0.9
set pm3d map interpolate 20,20
# plot the heatmap
set cntrparam bspline
set cntrparam points 10
set cntrparam levels increment -6,-6,-18
set contour surface
set palette rgb 33,13,10
set cbrange [-18:0]
unset border
unset xtics
unset ytics
set angles degree
r = 3.31
set xrange[-r:r]
set yrange[-r:r]
set colorbox user origin 0.9,0.1 size 0.03,0.8
# load one of the following files:
#load 'linestyle.gp'
#load 'linetype.gp'
splot 'new_test.dat' title ' '
cbrange
仅定义为-18
,因此我相应地更改了轮廓级别(-24
未绘制)
我使用的两个“轮廓设置文件”是:
linetype.gp
:
set linetype 1 lc rgb "blue" lw 3
set linetype 2 lc rgb "black"
set linetype 3 lc rgb "orange"
set linetype 4 lc rgb "yellow"
linestyle.gp
:
set linetype 1 lc rgb "blue" lw 3
set linetype 2 lc rgb "black"
set linetype 3 lc rgb "orange"
set linetype 4 lc rgb "yellow"
设置样式增量用户
set style line 1 lc rgb 'blue' lw 3
set style line 2 lc rgb 'black'
set style line 3 lc rgb 'orange'
set style line 4 lc rgb 'yellow'
两者都提供相同的输出图像:
要将其用于整个脚本,只需直接在splot
命令之前加载两个文件中的一个即可。这将提供以下输出:
在你提出关于轮廓的第一个问题后,我正要提交一份bug报告,但事实证明很难将其归结为具体的问题
#HOW TO CONTROL LINE COLOR AND WIDTH FOR CONTOUR LINES:
#the number of contour lines and their level is controlled using the 'set cntrparam' command, above
#the 'set cntrparam' has the format 'start,increment,end' for the line positions
#note that the end level is listed at the top of the key/legend for the lines!
#line style 1 is used elsewhere, not for contour lines
#line style 2 is used for the style of the last line (e.g. end, or the last one drawn)
#line styles for other lines begins further down the list of styles and works UPWARDS to line style 2
#example 1: three lines at -40, -30, and -20
# set cntrparam levels increment -20,-10,-40
# set style line 1 lw 0.5 lc "grey30"
# set style line 2 lw 0.5 lc "blue"
# set style line 3 lw 0.5 lc "white"
# set style line 4 lw 0.5 lc "red"
# This results in:
# -20 line color is RED
# -30 line color is WHITE
# -40 line color is BLUE
#
#example 2: four lines at -35, -30, -25, and -20
# set cntrparam levels increment -20,-5,-35
# set style line 1 lw 0.5 lc "grey30"
# set style line 2 lw 0.5 lc "blue"
# set style line 3 lw 0.5 lc "white"
# set style line 4 lw 0.5 lc "red"
# set style line 5 lw 0.5 lc "yellow"
# This results in:
# -20 line color is YELLOW
# -25 line color is RED
# -30 line color is WHITE
# -35 line color is BLUE