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

标签 bitmap gnuplot histogram

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

我的数据表看起来像:

1 163073164
4 185122087
3 255242000
8 255255255
3 000162232
1 181230029
1 127127127
1 136000021
3 200191231

我想通过使用 gnu 绘图直方图样式用自己的颜色绘制每个颜色条。

我只是通过使用“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

我收到此错误消息:
gnuplot> plot "histo.dat" using 1:xticlabels(2) lc variable no title
                                              ^
         "histo.plt", line 9: Bad data on line 1

谁能给我一个提示或正确的命令?

最好的问候罗伯特

最佳答案

好问题。我设法使用 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.

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

Colorful bar chart

关于bitmap - GNUPLOT 每个直方图条具有不同的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11664797/

相关文章:

r - 有轴,但直方图中没有框架(R :ggplot2)

r - 谁能解释为什么创建具有两个条件的直方图显示 R 中的分布不正确?

c# - 如何从位图中删除白色背景色

android - 从位图创建可绘制对象

Gnuplot:如何为不同单位添加 y2 轴比例

gnuplot - gnuplot 中的函数界限

C#:使用位图时如何减少内存和 CPU 消耗?

java - 当屏幕太大时出现错误

plot - Gnuplot:使用线或线点仅绘制数据集的特定值

matlab - MATLAB 直方图中条形的颜色