如何使用gnuplot突出显示图形的区域

4
我希望有人能帮忙解决这个问题。我正在使用gnuplot 5.0.0绘制雷达(或蜘蛛网)图:

enter image description here

所有轴的刻度和范围都相同。1及1以上的数字具有特殊含义,我想突出显示。

我考虑了三件事情,可以增加可见性:

  1. 只需使标记为1(标记为“Limit”)加粗。如何突出显示特定的刻度和标签?

  2. 我还可以突出显示级别为1的圆形虚线

  3. 在图中,我希望半径大于1的背景颜色不同。

如何实现上述三个选项之一?当然,三个选项都是理想的,但仅与该值的其余部分有所区别即可。

以下是链接中生成图表的内容:

set term x11
set title "My title "
set polar
set angles degrees
npoints = 6

a1 = 360/npoints*1
a2 = 360/npoints*2
a3 = 360/npoints*3
a4 = 360/npoints*4
a5 = 360/npoints*5
a6 = 360/npoints*6

set grid polar 360
set size square
set style data lines

unset border

set grid ls 0
set linetype 1 lc rgb 'red' lw 2 pt 7 ps 2

M=2.2
set arrow from 0,0 to first M*cos(a1), M*sin(a1)
set arrow from 0,0 to first M*cos(a2), M*sin(a2)
set arrow from 0,0 to first M*cos(a3), M*sin(a3)
set arrow from 0,0 to first M*cos(a4), M*sin(a4)
set arrow from 0,0 to first M*cos(a5), M*sin(a5)
set arrow from 0,0 to first M*cos(a6), M*sin(a6)

a1_min = 0
a1_max = 1
a2_min = 0
a2_max = 1
a3_min = 0
a3_max = 1
a4_min = 0
a4_max = 1
a5_min = 0
a5_max = 1
a6_min = 0
a6_max = 1

set label "M1" at M*cos(a1),M*sin(a1) center offset char 1,1
set label "M2" at M*cos(a2),M*sin(a2) center offset char 1,1
set label "M3" at M*cos(a3),M*sin(a3) center offset char 1,1
set label "M4" at M*cos(a4),M*sin(a4) center offset char 1,1
set label "M5" at M*cos(a5),M*sin(a5) center offset char 1,1
set label "M6" at M*cos(a6),M*sin(a6) center offset char 1,1


set xrange [0:1]
set yrange [0:1]

set xtics axis 0,0.5,M
unset ytics

set rrange [0:M]

set rtics (""0,""0.25,""0.5,""0.75,"Limit"1,""1.25,""1.50,""1.75,""2)
set rtics scale 0 format ''

set style fill transparent solid 0.5
set style function filledcurves y1=0.5
set grid noxtics nomxtics noytics nomytics front


plot  '-' u ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:($1==6?a6:$1)))))):($1==1?(($2-a1_min)/(a1_max-a1_min)):($1==2?(($2-a2_min)/(a2_max-a2_min)):($1==3?(($2-a3_min)/(a3_max-a3_min)):($1==4?(($2-a4_min)/(a4_max-a4_min)):($1==5?(($2-a5_min)/(a5_max-a5_min)):($1==6?(($2-a6_min)/(a6_max-a6_min)):$1)))))) w filledcurve lt 1 title "AAA",\
 '-' u ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:($1==6?a6:$1)))))):($1==1?(($2-a1_min)/(a1_max-a1_min)):($1==2?(($2-a2_min)/(a2_max-a2_min)):($1==3?(($2-a3_min)/(a3_max-a3_min)):($1==4?(($2-a4_min)/(a4_max-a4_min)):($1==5?(($2-a5_min)/(a5_max-a5_min)):($1==6?(($2-a6_min)/(a6_max-a6_min)):$1)))))) w filledcurve lt 2 title "BBB"

1 2.1
2 1
3 0.1
4 0.5
5 0.5
6 0.1
1 2.1
EOF
1 2.2
2 0.9
3 0.9
4 0.2
5 0.3
6 0.1
1 2.2
EOF
set output

目前,Google Drive要求人们获得权限才能查看您的图表。 - Miguel
谢谢你告诉我。我刚刚把它改成了让任何有链接的人都能查看。 - Asttor
我为您上传了这张图片。 - Miguel
您可以使用增强文本来设置加粗的tics标签:_set xtics add ("{/:Bold Limit}" 1)_。 - Karl
为了在网格线上进行突出显示,您可以绘制一个圆形(“set object circle”)或者绘制它:plot ....,[phi=0:2*pi]“+”us(sin(phi)):(cos(phi)) w l dt 2 lw 2 - Karl
谢谢Miguel和Karl。我无法使粗体tic标签起作用,但“set object circle”确实可以:在0,0处设置对象2的圆形,大小为1 fc rgb“#CCFFCC”,在fs solid后面。 - Asttor
1个回答

3
我已经稍微修改了你的脚本,现在你可以轻松地调整网页上的臂数。另外为1 >r > M添加了一个彩色背景。
顺便说一下,在结束时不需要重新输入第一个数据点来关闭轮廓。
更新:也就是说,不应该这样做。然而,即使给“with filledcurve”选项传入了“closed”参数,最后一个点和第一个点之间的线段也会丢失。我想知道这是否是一个Bug。
set term wxt
set title "My title "
set polar
set angles degrees

set grid polar 360
set size square
set style data lines
set key top left

unset border

set grid ls 0
set linetype 1 lc rgb 'red' lw 2 pt 7 ps 2

M=2.2
npoints = 7

minima = "0 0 0 0 0 0 0" # adjust and add more as necessary
maxima = "1 1 1 1 1 1 1"

a(n) = 360./npoints*n
amin(n) = 0.0 + word(minima,int(n))
amax(n) = 0.0 + word(maxima,int(n))

do for [i=1:npoints] {
    set arrow i from 0,0 to first M*cos(a(i)), M*sin(a(i))
    set label i sprintf("M%.f",i) at M*cos(a(i)),M*sin(a(i)) \
        center offset char 1,1
}

set object 1 circle at 0,0 size M fillc rgb "yellow" behind
set object 2 circle at 0,0 size 1 fillc rgb "white" behind

set xrange [0:1]
set yrange [0:1]

set xtics axis 0,0.5,M
unset ytics

set rrange [0:M]

set rtics (""0,""0.25,""0.5,""0.75,"{/:Bold Limit}"1,""1.25,""1.50,""1.75,""2)
set rtics scale 0 format ''

set style fill transparent solid 0.5
set style function filledcurves y1=0.5
set grid noxtics nomxtics noytics nomytics front

plot '-' us (a($1)):(($2-amin($1))/(amax($1)-amin($1))) \
        w filledcurve closed lt 1 title "AAA",\
     '-' us (a($1)):(($2-amin($1))/(amax($1)-amin($1))) \
         w filledcurve closed lt 2 title "BBB"

1 2.1
2 1
3 0.1
4 0.5
5 0.5
6 0.1
7 0.5
EOF
1 2.2
2 0.9
3 0.9
4 0.2
5 0.3
6 0.1
7 1.8
EOF

Karl,这远远超出了我的要求。我会测试你的更改并回报。自从我发布问题以来,我学到了一些东西。非常感谢你抽出时间来做这件事。 - Asttor
Karl,我试了一下你修改过的脚本,确实好用。我采纳了它,再次感谢。你的版本使用向量和for循环看起来更加优雅。我也曾经使用过向量和for循环,但这是在生成我的脚本的代码中完成的。 - Asttor
我刚刚按照你在原问题中的要求添加了一个有颜色的背景。请注意“behind”选项,可以将填充对象放置在网格和坐标轴后面。 - Karl
再次感谢你,Karl。我认为你的最新回答是我的问题的最佳答案。我该如何关闭这个帖子并标记为已解决? - Asttor
我认为这是不可能的,你只能给我的答案点赞,据我所知。 - Karl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接