Car*_*rto 6 plot graph gnuplot
我想用Gnuplot制作一个蜘蛛(又名雷达/星)图,其中不同的轴有独立的比例.我能够产生这样使用OriginPro(商业)的阴谋,但gnuplot的,我只能设定统一的比例雷达图.
(csv文件)数据集如下所示(第一行是列标签):
# FEATURE, Product_A, Product_B, Product_C, Product_D
attribute_1, 2, 10, 7, 3.5
attribute_2, 1, 0.5, 3,4
attribute_3, 37, 58, 49, 72
attribute_4, 1985, 1992, 2006, 2010
attribute_5, 0.1, 0.5, 0.3, 0.8
我正在寻找的情节是这样的:https://www.dropbox.com/s/uvqubzqvm6puhb8/spider.pdf - 正如你所看到的,每个轴代表不同的属性,并且有自己的比例.
我想Gnuplot的起始代码是:
set polar
set grid polar
set angles degrees
set size square
set style data filledcurves
但我不知道该怎么办.有什么建议?
@george 的答案帮助我弄清楚如何重新排列数据集,以便从中选择相应的属性数据。因为我还在寻找不同蜘蛛轴的不同范围尺度,所以除了 @george 的建议之外,我认为对公共 [0:1] 范围进行特定于轴的标准化可以解决问题。那么主要的修改就和命令using的字段相关了plot。
代码相当长,我相信它可以优化。它还可以合并到脚本或简单的 C 代码中,以便让用户决定轴的数量(属性的数量)以及每个特定轴的不同范围(最小值、最大值)。
以下示例针对 2 个产品的 5 个属性进行比较。这里显示了绘图结果图像:
set nokey
set polar
set angles degrees
npoints = 5
a1 = 360/npoints*1
a2= 360/npoints*2
a3= 360/npoints*3
a4= 360/npoints*4
a5= 360/npoints*5
set grid polar 360.
set size square
set style data lines
unset border
set arrow nohead from 0,0 to first 1*cos(a1) , 1*sin(a1)
set arrow nohead from 0,0 to first 1*cos(a2) , 1*sin(a2)
set arrow nohead from 0,0 to first 1*cos(a3) , 1*sin(a3)
set arrow nohead from 0,0 to first 1*cos(a4) , 1*sin(a4)
set arrow nohead from 0,0 to first 1*cos(a5) , 1*sin(a5)
a1_max = 10
a2_max = 5
a3_max = 100
a4_max = 2020
a5_max = 1
a1_min = 0
a2_min = 0
a3_min = 50
a4_min = 1980
a5_min = 0
set label "(0:10)" at cos(a1),sin(a1) center offset char 1,1
set label "(0:5)" at cos(a2),sin(a2) center offset char -1,1
set label "(50:100)" at cos(a3),sin(a3) center offset char -1,-1
set label "(1980:2020)" at cos(a4),sin(a4) center offset char 0,-1
set label "(0:1)" at cos(a5),sin(a5) center offset char 3,0
set xrange [-1:1]
set yrange [-1:1]
unset xtics
unset ytics
set rrange [0:1]
set rtics (""0,""0.25,""0.5,""0.75,""1)
plot '-' using ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:$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))))) w l
1 8
2 3
3 67
4 2000
5 0.2
1 8
plot '-' using ($1==1?a1:($1==2?a2:($1==3?a3:($1==4?a4:($1==5?a5:$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))))) w l
1 6
2 1.5
3 85
4 2010
5 0.5
1 6