1set terminal dumb enhanced
2#set terminal caca driver ncurses color enhanced size 80,43 inverted charset ascii
3set datafile separator ','
4stats filename u 2 noout      # get STATS_sum (sum of column 2)
5
6ang(x)=x*360.0/STATS_sum        # get angle (grades)
7perc(x)=x*100.0/STATS_sum       # get percentage
8
9
10set palette color
11set size square                 # square canvas
12set xrange [-1:1.5]
13set yrange [-1.25:1.25]
14set style fill solid 1
15
16unset border
17unset tics
18unset key
19
20set linetype 1 linecolor rgb 'red'
21set linetype 2 linecolor rgb 'green'
22set linetype 3 linecolor rgb 'blue'
23set linetype 4 linecolor rgb 'cyan'
24set linetype 5 linecolor rgb 'magenta'
25set linetype 6 linecolor rgb 'white'
26set linetype 7 linecolor rgb 'yellow'
27set linetype 8 linecolor rgb 'orange'
28
29Ai = 0.0; Bi = 0.0;             # init angle
30mid = 0.0;                      # mid angle
31i = 0; j = 0;                   # color
32yi  = 0.0; yi2 = 0.0;           # label position
33
34plot filename u (0):(0):(1):(Ai):(Ai=Ai+ang($2)):(i=i+1) with circle linecolor var,\
35filename u (1.5):(yi=yi+0.5/STATS_records):($1) w labels,\
36filename u (1.0):(yi2=yi2+0.5/STATS_records):(j=j+1) w p pt 5 ps 2 linecolor var,\
37filename u (mid=Bi+ang($2)*pi/360.0, Bi=2.0*mid-Bi, 0.5*cos(mid)):(0.5*sin(mid)):(sprintf('%.0f (%.1f\%)', $2, perc($2))) w labels
38