使用 CSV 标题的 Gnuplot 多列图

Gnuplot multi column plot using CSV headings

我正在努力获得一个 multi-column 条形图/直方图,将我的输入作为带标题的 CSV。以及显示 {wcfiles,wclines,clocfiles,cloclines} 属性的密钥。

$summary << EOD
browser,wcfiles,wclines,clocfiles,cloclines
webkitgtk-2.28.2,19472,4710385,18620,3120740
firefox-78.0.1,289298,43627834,240137,24371602
chromium-83.0.4103.116,420343,100340817,269434,49597826
EOD
set datafile separator ','
set yrange [0:*]      # start at zero, find max from the data
set style fill solid border -1
set ytics format "%.0s%c" #  will generate labels 100k 200k 300k ... 1M
set title 'sloc the Web'
plot '$summary' using 0:2:([=10=]+1):xtic(1) with boxes lc variable,\
   "" u 3 title "wclines",\
   "" u 4 title "clocfiles"

查看@Ethan 提到的例子。 在您的情况下,您应该 set logscale y,否则将很难可视化具有几个数量级差异的值。

代码:

### histogram clustered
reset session

$Data <<EOD
browser,wcfiles,wclines,clocfiles,cloclines
webkitgtk-2.28.2,19472,4710385,18620,3120740
firefox-78.0.1,289298,43627834,240137,24371602
chromium-83.0.4103.116,420343,100340817,269434,49597826
EOD

set datafile separator ','
set title 'sloc the Web'

set yrange [1000:*]
set logscale y
set ytics format "%.0s%c"

set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9

plot $Data u 2:xtic(1) ti col,\
     '' u 3 ti col,\
     '' u 4 ti col
### end of code

结果: