【问题标题】:How to highlight regions of plot with gnuplot如何使用 gnuplot 突出显示绘图区域
【发布时间】:2015-06-04 16:55:48
【问题描述】:

如果有人可以帮助解决这个问题,我将不胜感激。 我正在使用 gnuplot 5.0.0 处理雷达(或蜘蛛网)图:

所有轴的比例和范围都是相同的。大于等于 1 的数字具有特殊含义,我想强调这一点。

我正在考虑三件可以提高知名度的事情:

  1. 只需将 1 处的刻度线(标记为“限制”)加粗。我怎么能只突出一个特定的刻度和标签?

  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 要求人们有权查看您的图表。
  • 感谢您告诉我。我只是将其更改为让知道链接的任何人都可以查看它。
  • 我为你上传了图片
  • 您可以使用增强文本来设置粗体 ticslabel:set xtics add ("{/:Bold Limit}" 1)
  • 为了突出显示网格线,您可以画一个圆(“设置对象圆”)或绘制它:plot ...., [phi=0:2*pi] "+" 我们 (sin(phi)):(cos(phi)) w l dt 2 lw 2

标签: gnuplot highlight radar-chart


【解决方案1】:

我冒昧地简化了您的脚本,您现在可以轻松地调整网络中的臂数。还为 1 >r > M 添加了彩色背景。

顺便说一句,没有必要在最后再次输入第一个数据点来关闭轮廓。 更新:也就是说,不应该有。然而,最后一点和第一点之间的线消失了,即使将“封闭”选项赋予“填充曲线”也是如此。我想知道这是否是一个错误。

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,我试过你的调整脚本,它可以工作。我采用了它。再次感谢。使用向量和 for 循环,您的版本看起来更优雅。我也使用了向量和 for 循环,但我在生成脚本的代码中这样做了。
  • 我刚刚添加了一个彩色背景,就像您在原始问题中要求的那样。请注意“后面”选项将填充对象放置在网格和轴后面。
  • 再次感谢卡尔。我认为您的最新意见是对我的问题的最佳答案。如何关闭此主题并将其标记为已回答?
  • 我不认为这是可能的,你只能赞成我的回答,afaik。
猜你喜欢
  • 2018-09-18
  • 2011-01-19
  • 2012-08-21
  • 2011-04-11
  • 1970-01-01
  • 2020-04-18
  • 1970-01-01
  • 2013-12-18
  • 1970-01-01
相关资源
最近更新 更多