在gnuplot中按角度和距原点的径向距离对数据进行排序

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

对于上下文:我正在绘制具有特定能量值的布里渊区中一些能带的交点的 k_x,k_y 坐标。

但是,问题可以大大简化。

  • 我的数据是两个圆环的形式
  • 我需要连接外环中gnuplot中的所有点和内环中的所有点,同时确保环不相互连接

Image shows the current state of my band plot (PS. pls ignore the anomalous point towards the bottom right I am ignoring this until the bandplot is better):

  • 到目前为止,我已经实现了角度排序,但我不知道如何分离两个环。我认为使用某种毕达哥拉斯径向距离排序可能会最容易完成,但我正在努力实现这一点。

通过以下 gnuplot 文件“kmesh.plt”实现:

set xrange [-0.1 : 0.1]
set title "2D k-mesh plot at 20meV above CBM"
set terminal pdfcairo enhanced font "DejaVu" transparent 
fontscale 1 size 5.00in, 5.00in
set output "kmesh.pdf"
set encoding iso_8859_1
set size ratio 0 1.0,1.0
set ylabel "k_y coordinate"
set xlabel "k_x coordinate"
set yrange [ -0.1 : 0.1 ]
unset key
set ytics 0.05 scale 1 nomirror out
set mytics 2
set parametric
set trange [-10:10]
set multiplot
set style data linespoints
plot "kmesh.dat" using 1:2:(atan2($2,$1)):(atan2($2,$1)) smooth         
zsort
unset multiplot
gnuplot gfortran
1个回答
0
投票

这主要是一个澄清请求,而不是一个正确的答案(评论中没有足够的空间)。

您能否澄清一下您的数据文件第 1 列和第 2 列中的具体内容? [x,y] 笛卡尔坐标? [θ,r] 极坐标?

你的脚本有点乱。它说

set parametric
,但参数形式适用于函数,而不是数据文件。您的意思是
set polar
吗?然后它说
set multiplot
但后面只有一个情节。

我认为绘图命令中的第 3 个

using
字段将被解释为排序操作的 z,但实际上是 θ(假设第 1 列和第 2 列是 x 和 y);这很聪明。但是第四个字段的用途是什么?

下面的命令可能会执行您想要的操作,但如果没有您的数据样本,我无法确定。

set xrange [-0.1 : 0.1]; set yrange [-0.1 : 0.1]
set size square
R(x,y) = sqrt(x*x+y*y)
theta(x,y) = atan2(y,x)
gap = ??
set style data linespoints
set datafile missing NaN
plot DATA using (R($1,$2) < gap ? $1 : NaN) : ($2) : theta($2,$1) smooth zsort,
     DATA using (R($1,$2) > gap ? $1 : NaN) : ($2) : theta($2,$1) smooth zsort

备注:

  • 无需使用参数模式或多图。使用极坐标模式是一种选择,但如果数据采用笛卡尔坐标,我认为这不会更容易。
  • 我不确定程序对 theta 进行排序并根据 R 进行过滤的顺序。如果引入间隙,您想要连接的点可能不相邻,并且线路将被中断。
    set datafile missing NaN
    可以缓解这种情况。
© www.soinside.com 2019 - 2024. All rights reserved.