GNUPLOT Each Histogram Bar with different color

前端 未结 2 808
失恋的感觉
失恋的感觉 2021-02-08 13:07

I want to visualize the amount of different colors of a bitmap file.

My Datasheet looks like:

1 163073164
4 185122087
3 255242000
8 255255255
3 00016223         


        
相关标签:
2条回答
  • 2021-02-08 13:30

    I just edit something and now it works.

    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. 
    
    0 讨论(0)
  • 2021-02-08 13:35

    Nice question. I've managed to make it work using the boxes style as opposed to the histogram style you were originally using. I don't think that should make too much of a difference though:

    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.
    

    If you're unfamiliar with pseudo-column 0, it is (essentially) the line number in the datafile. I don't usually post the output of these things, but this makes one very colorful plot!

    Colorful bar chart

    0 讨论(0)
提交回复
热议问题