GNUPLOT每个直方图条具有不同的颜色

use*_*847 10 gnuplot bitmap histogram

我想要可视化位图文件的不同颜色的数量.

我的数据表看起来像:

1 163073164
4 185122087
3 255242000
8 255255255
3 000162232
1 181230029
1 127127127
1 136000021
3 200191231
Run Code Online (Sandbox Code Playgroud)

我想用gnu plot直方图样式绘制每个颜色条都有自己的颜色.

我只是尝试使用"lc变量",但它不起作用.:-(

我的GNUPLOT脚本现在:

set style data histograms 
set boxwidth 1
set grid
set style histogram cluster gap 0  
set style fill solid 1.0 border -1
set yrange [0:*]
set xrange [0:*]
set xtics border in scale 0,10  nomirror rotate by -45  offset character 0, 0, 0 left
plot "histo.dat" using 1:xticlabels(2) lc variable no title
#EOF
Run Code Online (Sandbox Code Playgroud)

我有这个错误信息:

gnuplot> plot "histo.dat" using 1:xticlabels(2) lc variable no title
                                              ^
         "histo.plt", line 9: Bad data on line 1
Run Code Online (Sandbox Code Playgroud)

任何人都可以给我一个提示或正确的命令吗?

最好的问候Robert

mgi*_*son 22

好问题.我设法使用boxes样式而不是histogram你最初使用的样式.我不认为这应该会产生太多差异:

set boxwidth 1
set grid
set style fill solid 1.0 border -1
set yrange [0:*]
set xrange [-.5:*]
set xtics border in scale 0,10  nomirror rotate by -45  
plot "histo.dat" using ($0):1:($0):xticlabels(2) w boxes lc variable notitle
                        #^boxes centered on 0,1,2,3,....
                           #^data column
                              #^ linecolor column.  first box has linecolor corresponding to ls 0, second box has linecolor corresponding to ls 1, etc ...
                                   #^ xticlabels (apparently) come last.
Run Code Online (Sandbox Code Playgroud)

如果您不熟悉伪列0,它(基本上)是数据文件中的行号.我通常不会发布这些东西的输出,但这会产生一个非常丰富多彩的情节!

彩色条形图