简单的条形图:
set boxwidth 0.5
set style fill solid
plot "data.dat" using 1:3:xtic(2) with boxes
数据.dat:
0 label 100
1 label2 450
2 "bar label" 75
如果你想以不同的方式设计你的酒吧,你可以这样做:
set style line 1 lc rgb "red"
set style line 2 lc rgb "blue"
set style fill solid
set boxwidth 0.5
plot "data.dat" every ::0::0 using 1:3:xtic(2) with boxes ls 1, \
"data.dat" every ::1::2 using 1:3:xtic(2) with boxes ls 2
如果您想为每个条目执行多个条形:
数据.dat:
0 5
0.5 6
1.5 3
2 7
3 8
3.5 1
gnuplot:
set xtics ("label" 0.25, "label2" 1.75, "bar label" 3.25,)
set boxwidth 0.5
set style fill solid
plot 'data.dat' every 2 using 1:2 with boxes ls 1,\
'data.dat' every 2::1 using 1:2 with boxes ls 2
如果你想玩点技巧并使用一些简洁的 gnuplot 技巧:
Gnuplot 有伪列,可以用作颜色索引:
plot 'data.dat' using 1:2:0 with boxes lc variable
此外,您可以使用函数来选择您想要的颜色:
mycolor(x) = ((x*11244898) + 2851770)
plot 'data.dat' using 1:2:(mycolor($0)) with boxes lc rgb variable
注意:您必须添加一些其他基本命令才能获得与示例图像相同的效果。