Gnuplot multi column plot using CSV headings

拟墨画扇 提交于 2020-07-23 06:23:38

问题


I'm struggling to get a multi-column bar chart / histogram going with my input as a CSV with headings. As well as the key showing the {wcfiles,wclines,clocfiles,cloclines} attributes.

$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:($0+1):xtic(1) with boxes lc variable,\
   "" u 3 title "wclines",\
   "" u 4 title "clocfiles"

回答1:


Check the examples @Ethan mentioned. In your case you should set logscale y, otherwise it will be difficult to visualize values with differences of several orders of magnitude.

Code:

### 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

Result:



来源:https://stackoverflow.com/questions/62828141/gnuplot-multi-column-plot-using-csv-headings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!