你如何在 gnuplot 中绘制条形图? [英] How do you plot bar charts in gnuplot?
本文介绍了你如何在 gnuplot 中绘制条形图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在带有文本标签的 gnuplot 中绘制条形图?
How do you plot bar charts in gnuplot with text labels?
推荐答案
简单条形图:
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 具有可用作着色索引的伪列:
Gnuplot has psuedo-columns that can be used as the index to color:
plot 'data.dat' using 1:2:0 with boxes lc variable
您还可以使用函数来选择您想要的颜色:
Further you can use a function to pick the colors you want:
mycolor(x) = ((x*11244898) + 2851770)
plot 'data.dat' using 1:2:(mycolor($0)) with boxes lc rgb variable
注意:您必须添加一些其他基本命令才能获得与示例图像相同的效果.
Note: you will have to add a couple other basic commands to get the same effect as the sample images.
这篇关于你如何在 gnuplot 中绘制条形图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文