gnuplot轮廓线颜色:设置样式线和设置线型不工作 [英] gnuplot contour line color: set style line and set linetype not working

查看:3227
本文介绍了gnuplot轮廓线颜色:设置样式线和设置线型不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照之前的Stackoverflow问题描述绘制数据:
gnuplot 2D极坐标图与3D数据集的热图 - 可能?
大多数情况下,它对我来说工作得很好,我下了一些小细节。其中之一是如何对轮廓线颜色和线宽进行控制。网上有很多关于使用设置样式增量用户的帖子,然后通过设置样式行1定义用户样式lc rgbbluelw 2 等。在理论上,这应该强制splot使用新定义的样式绘制线。我试过它,它没有工作。此外,当我通过我的gnuplot安装去帮助页面,我发现这个用法已经弃用与我的版本(版本4.7 patchlevel 0最后修改2013-07-25)。建议使用set linetype,这会为gnuplot的当前调用永久更改gnuplot行样式的特性。

I am plotting data as described in a previous Stackoverflow question: gnuplot 2D polar plot with heatmap from 3D dataset - possible? Mostly it is working well for me, and I am down to some small details. One of these is how to exert control over the contour line colors and linewidths. There are lots of posts on the web regarding using set style increment user followed by definition of user style via set style line 1 lc rgb "blue" lw 2 etc. In theory this was supposed to force splot to plot lines using the newly defined styles. I tried it and it did not work. In addition, when I went to the help pages through my gnuplot install, I discovered that this usage is deprecated with my version (Version 4.7 patchlevel 0 last modified 2013-07-25). It was recommended to use set linetype instead, which changes the characteristics of the gnuplot line style permanently for the current invocation of gnuplot. Killing and restarting gnuplot restores the default linetype characteristics.

接下来,我重新启动了gnuplot,重新绘制了绘图,但没有重新定义轮廓线的任何线条样式或类型。当我看着我的情节,我可以看到线条颜色从青色,然后紫色,然后蓝色开始(例如像线型5,4,3或14,13,12等)。看起来好像线类型通过可用的样式返回。好吧,我想,我可以改变这些和生活的奇怪的行为。然而,在发出多个设置线型命令,将所有这些线类型改变为明显不同的东西(我通过运行 test 命令验证这些线类型命令后,轮廓线图表仍然具有与以前相同的颜色和线宽,我似乎不知道什么线型正在使用的轮廓线,所以我不能改变适当的线型。

Next, I restarted gnuplot, regenerated the plot without redefining any line style or type for the contour lines. When I looked at my plot, I could see that the line colors start with cyan, then purple, then blue (e.g. like line types 5,4,3 or 14,13,12, etc.). It seems as if the line types are going BACKWARDS through the available styles. OK, I thought, I can just change those and live with the odd behavior. However, after issuing multiple set linetype commands that changed all of these line types to something that would be obviously different (I verified these by running the test command, the contour lines on the plot still had the same color and line width as before. I can't seem to figure out what linetype is being used for the contour lines, so I can't change the appropriate linetype.

也许这种奇怪的行为是轮廓线的类型 set cntrparam levels increment -6,-6,-24 和负值和/或负增量会导致一些不可预测的行为?

Perhaps this odd behavior is a result of the contour line being of type set cntrparam levels increment -6,-6,-24 and the negative values and/or negative going increment are causing some unpredictable behavior?

我想知道如何知道什么行类型将用于该图中的等高线,以及是否如果用于构建表面图的线的数量改变,则这将改变。例如,下面的图使用13线来使用设置pm3d映射来生成表面。所以,让我们说N = 13线 - 有一个规则,服从第一轮廓线型。例如,我总是确保轮廓线样式将从N = 14开始?当输入数据中的线数量变化时,我会知道第一条和后续轮廓线将使用什么行类型。

I'd like to know how I can know what line type will be used for contour lines in this plot, and whether that will change if the number of lines used to build the surface plot change. For instance, the plot shown below uses 13 "lines" to generate the surface using set pm3d map. So let's say N=13 lines - is there a rule that is obeyed for the first contour linetype?. For instance, will I always be sure that the contour line style will start at N=14? I'd to know what line type will be used for the first and subsequent contour lines when the number of "lines" in my input data will vary.

底线是我需要应用某种风格用于每个轮廓级别的轮廓线。我想在输入数据改变时,为每个级别一致地使用相同的样式。绘图将始终使用相同的轮廓级别集:-6,-12,-18和-24。绘图数据总是具有大约0的最大z坐标,并从那里减少。

The bottom line is that I need to apply certain style to the contour lines used for each contour level. I want to consistently use the same style for each level when the input data changes. The plot will always use the same set of contour levels: -6, -12, -18, and -24. The plot data will always have a maximum "z" coordinate of about 0 and decrease from there.

Gnuplot命令如下所示。此图的数据集可以从这里下载:
http://audio.claub。 net / temp / new_test.dat

Gnuplot commands are shown below. The dataset for this plot can be downloaded here: http://audio.claub.net/temp/new_test.dat

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
unset key

set multiplot

# plot the heatmap

set cntrparam bspline
set cntrparam points 10
set cntrparam levels increment -6,-6,-24
set contour surface
#set style increment user           #NOTE: the commented out lines do not seem to affect color or width of the the contour lines no matter what number I use for the linetype
#set linetype 8 lc rgb "blue" lw 2
#set linetype 9 lc rgb "black" lw 1
#set linetype 10 lc rgb "orange" lw 1
#set linetype 11 lc rgb "yellow" lw 1

set palette rgb 33,13,10 #rainbow (blue-green-yellow-red)
set cbrange [-18:0]

unset border
unset xtics
unset ytics

set angles degree
r = 3.31 #This number is Log10(max frequency) - Log10(min frequency) of the polar frequency grid 
set xrange[-r:r]
set yrange[-r:r]
set colorbox user origin 0.9,0.1 size 0.03,0.8
splot 'new_test.dat'

# now plot the polar grid only
set style line 11 lc rgb 'black' lw 2 lt 0
set grid polar ls 11
set polar
set logscale r 10
set rrange[10:20000]
unset raxis
set rtics format '' scale 0
#set rtics axis scale 
set rtics (20,50,100,200,500,1000,2000,5000,10000,20000)
do for [i=-150:180:30] {
dum = r+0.15+0.05*int(abs(i/100))+0.05*int(abs(i/140))-0.05/abs(i+1)
set label i/30+6 at first dum*cos(i), first dum*sin(i) center sprintf('%d', i)
}
set label 20 at first 0, first -(log(20)/log(10)-1) center "20"
set label 100 at first 0, first -(log(100)/log(10)-1) center "100"
set label 200 at first 0, first -(log(200)/log(10)-1) center "200"
set label 1000 at first 0, first -(log(1000)/log(10)-1) center "1k"
set label 2000 at first 0, first -(log(2000)/log(10)-1) center "2k"
set label 10000 at first 0, first -(log(10000)/log(10)-1) center "10k"
set label 20000 at first 0, first -(log(20000)/log(10)-1) center "20k"
plot NaN w l
unset multiplot
unset output

没有控制轮廓线的绘图如下所示。我需要能够为轮廓线指定线颜色和宽度。如何?

The plot with no control over the contour lines is shown below. I need to be able to specify line color and width for the contour lines. How?

推荐答案

以下是如何更改轮廓线的线属性。我不能解释为什么是这样的方式,我只是通过测试发现了。不幸的是,没有关于这些细节的文档。

Here is how you can change the line properties of the contour lines. I can't explain why it is that way, I just found out by testing it. Unfortunately, there is no documentation about these details.

行为如下(使用4.6.3和4.7测试(2013-07-25和2013-09- 09),都显示相同的行为):

The behaviour is as follows (tested with 4.6.3. and 4.7 (2013-07-25 and 2013-09-09), all show the same behaviour):


  1. p>如果为 splot 指定 linetype ,表面本身将使用 lt 1 。在这种情况下,第一轮廓用 lt 3 绘制。是,与指定的增量相比,编号向后。但是你可以使用 set cntrparam levels增量-6,-6,-18 来设置cntrparam级别增量-18,6,-6
  1. If no linetype is specified for splot, the surface itself would use lt 1. In that case the first contour is drawn with lt 3. Yes, the numbering is backwards compared to the specified increment. But you can reverse it by using set cntrparam levels increment -6,-6,-18 or set cntrparam levels increment -18,6,-6

所有轮廓的 linewidth 是相同的,用于绘图命令的 linewidth ,更改它使用eg splot'new_test.dat'lw 3

The linewidth of all contours is the same and also equal to the linewidth used for the plotting command, to change it use e.g. splot 'new_test.dat' lw 3.


  1. 轮廓使用 linestyle ,其索引比绘图命令使用的索引高一个。

  1. The contours use the linestyle with an index by one higher than the one used by the plotting command.

你还必须定义第一个 linestyle ,它将被表面使用。如果未定义此样式,则轮廓将回到使用 linetype

You must also define the first linestyle, which would be used by the surface. If this style is not defined, the contours fall back to using linetype.

$ c> linewidth 取自第一个 linestyle ,所有 lw ls 被忽略。

The linewidth is taken from the first linestyle, all lw settings from the following ls are ignored.



使用自定义线型



Using customized linetypes


  1. 轮廓使用 linetype ,索引高出一个

所有 linetype 必须自定义,也是第一个,表面。 c>

All linetype must be customized, also the first, the one used by the surface. Otherwise the default settings are used.

lw / code>。

对于测试,我使用了您的数据和以下的脚本:

For testing I used your data and the following stripped down script:

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 wasn'

The cbrange is defined only down to -18, so I changed the contour levels accordingly (-24 wasn't drawn anyway).

两个'轮廓设置文件',我使用的是:

The two 'contour settings files', which I use are:

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 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'

两者都提供相同的输出图片:

Both give the same output image:

要在完整脚本中使用它,只需直接在 splot 命令。这会产生输出:

To use this for your complete script, just load one of the two files directly before the splot command. This gives the output:

在关于轮廓的第一个问题之后,我即将提交一个错误报告,但结果是很难将其归纳为具体问题。有了这个问题,它可能会更容易。我会看看是否有时间这样做。

After your first question about contours, I was about to submit a bug report, but it turned out to be rather difficult to boil it down to concrete questions. With this question it might be easier. I'll see if I find some time to do this.

这篇关于gnuplot轮廓线颜色:设置样式线和设置线型不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆