1

我进入了数据分析阶段,我需要在单个图中显示多个维度,以便更好地强调相关性。为每个数据点放置一个饼图将是最好的方法。在这里附加一个我在以下位置找到的数字:https ://andypope.info/charts/piedatamarkers.htm

如何在 Gnuplot 5.2 中生成这样的图表?我知道标准绘图类型是不可能的,我正在寻找一种解决方法。我会继续循环并使用 Python 制作一个生成这样一个情节的脚本。

在此处输入图像描述

4

1 回答 1

1

这是此处提到的示例的稍微简化的变体,尤其是 plot 命令更短更清晰。

饼图的半径要么是固定的:第 3 列中的值>0,要么是自动的:第 3 列中的值<0。在后一种情况下,圆的面积与列的总和成正比。可以选择圆弧颜色作为0xRRGGBB颜色。这个例子可以作为进一步改进和适应的起点。

代码:

### plot with piecharts as points
reset session

$Data <<EOD
# x y    r  c1   c2   c3   c4   c5
2   16  -1  1.0  1.0  1.0  0.5  3.0
3    5  -1  0.8  0.7  0.5  0.9  0.8
7   15  -1  1.5  1.3  1.4  2.1  1.2
11  10  -1  5.6  8.7  3.1  3.1  9.4
12  19  -1  1.7  2.5  3.3  1.0  0.9
17   3  -1  4.1  5.1  1.4  0.5  5.3
19  14  -1  0.1  0.2  0.3  0.4  0.5
22  17  -1  2.1  2.2  3.2  4.2  1.5
EOD

stats $Data nooutput    # get the number of columns
colMax = STATS_columns
colMin = 4              # starting column for data
Scale = 0.3             # general scaling of circles
set angle degrees

Part(i) = sum [col=colMin:i] column(col)
Total(n) = Part(colMax)
Radius(r) = Scale * (r<0 ? sqrt(Total(0)) : r)    # radius<0: automatic calculation, proportional to sqrt
ArcStart = 90                                     # pie-chart start angle: 90=twelve o'clock
ArcDir = -1                                       # direction: -1 = clockwise, 1 = counterclockwise
ArcFrom(i) = ArcDir*Part(int(i)+(ArcDir<0?0:-1))/Total(0)*360 + ArcStart
ArcTo(i)   = ArcDir*Part(int(i)+(ArcDir<0?-1:0))/Total(0)*360 + ArcStart
ArcColor(i) = int(word("0xff0000 0x00ff00 0x0000ff 0xff00ff 0xffff00",i-colMin+1))

set xrange[0:25]
set yrange[0:25]
set grid xtics, ytics
set style fill solid 0.5 noborder

plot for [j=colMin:colMax] $Data u 1:2:(Radius($3)):(ArcFrom(j)):(ArcTo(j)):(ArcColor(j)) w circle lc rgb var notitle
### end of code

结果:

在此处输入图像描述

于 2020-12-08T10:01:49.803 回答