如何在gnuplot中绘制条形图? [英] How do you plot bar charts in gnuplot?

查看:924
本文介绍了如何在gnuplot中绘制条形图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gnuplot中使用文本标签绘制条形图?

解决方案

简单条形图:



  set boxwidth 0.5 
设置样式填充固体
绘图data.dat使用1:3:xtic(2)带框

data.dat:

  0 label 100 
1 label2 450
2bar label75

strong>如果您想以不同的方式设置您的酒吧样式,您可以执行以下操作:



 设置样式行1 lc rgbred
set style line 2 lc rgbblue

设置样式填充固体
设置盒宽0.5

绘制data.dateach :: 0: :0使用1:3:xtic(2)with boxes ls 1,\
data.datevery :: 1 :: 2 using 1:3:xtic(2)with boxes ls 2

如果您想为每个条目设置多个栏:



data.dat:

  0 5 
0.5 6
b
$ b 1.5 3
2 7


3 8
3.5 1

gnuplot:

 设置xtics(label0.25,label2 1.75,bar label3.25,)

set boxwidth 0.5
设置样式填充固体

绘图'data.dat'每2使用1:2框ls 1,\
'data.dat'每2 :: 1使用1:2与框ls 2



如果你想变得棘手,并使用一些整洁的gnuplot技巧:



Gnuplot有psuedo列可以用作颜色的索引: / p>

 使用1:2:0与方框lc变量
绘制data.dat'





此外,您可以使用函数来选择所需的颜色:

  mycolor )=((x * 11244898)+ 2851770)
使用1:2绘制'data.dat':(mycolor($ 0))带有框lc rgb变量
pre>



注意:您必须添加几个其他基本命令才能获得与示例图像相同的效果。


How do you plot bar charts in gnuplot with text labels?

解决方案

Simple bar graph:

set boxwidth 0.5
set style fill solid
plot "data.dat" using 1:3:xtic(2) with boxes

data.dat:

0 label       100
1 label2      450
2 "bar label" 75

If you want to style your bars differently, you can do something like:

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

If you want to do multiple bars for each entry:

data.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

If you want to be tricky and use some neat gnuplot tricks:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆