我已经把条形图和侏儒图堆在一起了。目前,我只获取数据文件,并手动设置数据标题。由于我要根据数据量对数据库进行排序,因此重新键入和查看订单需要花费时间。
这是我的Gnuplot文件:
set term pos eps font 20
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set key invert reverse right outside
set boxwidth 0.75
set format y "%.0f%%"
set style line 2 lc rgb "#EDEBE4" lt 1 lw 2
set style line 3 lc rgb "#A7ABA6" lt 1 lw 2
set title "Classification"
set ylabel "Percentage"
set xlabel "System"
set yrange [0:100]
set output 'output.eps'
plot 'datafile' \
using($2):xtic(1) t "stack-1" lt -1 fs pattern 3 , \
'' using($3) t "stack-2" lt -1 fs pattern 2, \
'' using($4) t "stack-3" lt -1 fs pattern 5, \
'' using($5) t "stack-4" lt -1 fs pattern 9, \
'' using($6) t "stack-5" ls 3, \
'' using($7) t "stack-6" lt -1 fs pattern 6, \
'' using($8) t "stack-7" lt -1 fs pattern 4, \
'' using($9) t "stack-8" ls 2 这是我当前的数据文件:
CS 35.08 33.12 22.49 3.72 2.73 1.03 1.76 0.08
FL 58.22 9.36 21.46 4.34 3.65 2.97 0.00 0.00
HB 40.27 19.29 18.52 14.37 6.13 0.91 0.29 0.21
HD 30.32 22.51 31.63 1.10 9.51 2.53 1.50 0.90
MR 34.65 24.37 15.59 7.46 15.42 1.56 0.66 0.29
ZK 29.65 18.54 30.63 6.91 9.46 1.28 2.85 0.68
All 36.74 23.88 22.01 7.40 7.18 1.42 1.06 0.31我必须将我的数据文件更改为这样:
stacked-1 stack-2 stack-3 stack-4 stack-5 stack-6 stack-7 stack-8
CS 35.08 33.12 22.49 3.72 2.73 1.03 1.76 0.08
FL 58.22 9.36 21.46 4.34 3.65 2.97 0.00 0.00
HB 40.27 19.29 18.52 14.37 6.13 0.91 0.29 0.21
HD 30.32 22.51 31.63 1.10 9.51 2.53 1.50 0.90
MR 34.65 24.37 15.59 7.46 15.42 1.56 0.66 0.29
ZK 29.65 18.54 30.63 6.91 9.46 1.28 2.85 0.68
All 36.74 23.88 22.01 7.40 7.18 1.42 1.06 0.31产出:

如何从数据文件中的第一行自动创建条形图标题/图例?另外,我的脚本仍然需要手动使用模式样式。谢谢!
发布于 2014-06-30 08:06:44
使用title columnhead(2),您可以选择某个列的标题作为键项。所以您的plot命令变成
plot 'datafile' \
using 2:xtic(1) title columnhead(1) lt -1 fs pattern 3 , \
'' using 3 title columnhead(2) lt -1 fs pattern 2, \
'' using 4 title columnhead(3) lt -1 fs pattern 5, \
'' using 5 title columnhead(4) lt -1 fs pattern 9, \
'' using 6 title columnhead(5) ls 3, \
'' using 7 title columnhead(6) lt -1 fs pattern 6, \
'' using 8 title columnhead(7) lt -1 fs pattern 4, \
'' using 9 title columnhead(8) ls 2 这是相当冗长的,因为您的第一列没有标题,因此从其中选择标题的列由用于值的列中的一列关闭。
如果要为第一列插入一个虚拟头,那么就可以使用set key autotitle columnheader了。
将datafile更改为
desc stacked-1 stack-2 stack-3 stack-4 stack-5 stack-6 stack-7 stack-8
CS 35.08 33.12 22.49 3.72 2.73 1.03 1.76 0.08
FL 58.22 9.36 21.46 4.34 3.65 2.97 0.00 0.00
HB 40.27 19.29 18.52 14.37 6.13 0.91 0.29 0.21
HD 30.32 22.51 31.63 1.10 9.51 2.53 1.50 0.90
MR 34.65 24.37 15.59 7.46 15.42 1.56 0.66 0.29
ZK 29.65 18.54 30.63 6.91 9.46 1.28 2.85 0.68
All 36.74 23.88 22.01 7.40 7.18 1.42 1.06 0.31然后使用
set key invert reverse right outside autotitle columnheader
plot 'datafile' \
using 2:xtic(1) lt -1 fs pattern 3 , \
'' using 3 lt -1 fs pattern 2, \
'' using 4 lt -1 fs pattern 5, \
'' using 5 lt -1 fs pattern 9, \
'' using 6 ls 3, \
'' using 7 lt -1 fs pattern 6, \
'' using 8 lt -1 fs pattern 4, \
'' using 9 ls 2 https://stackoverflow.com/questions/24482597
复制相似问题