【问题标题】:GNUPLOT Each Histogram Bar with different colorGNUPLOT 每个直方图条都有不同的颜色
【发布时间】:2012-07-24 18:34:33
【问题描述】:

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

我的数据表如下所示:

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

我想使用 gnu plot histogram style 绘制每个颜色条都有自己的颜色。

我只是尝试使用“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

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

最好的问候罗伯特

【问题讨论】:

    标签: bitmap gnuplot histogram


    【解决方案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,它(本质上)是数据文件中的行号。我通常不会发布这些东西的输出,但这会产生一个非常丰富多彩的情节!

    【讨论】:

      【解决方案2】:

      我只是编辑了一些东西,现在它可以工作了。

      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 left
      plot "histo.dat" using ($0):1:($2):xticlabels(3) w boxes lc rgb 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. 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-26
        相关资源
        最近更新 更多