GNUPLOT Each Histogram Bar with different color

℡╲_俬逩灬. 提交于 2019-12-03 06:15:20

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!

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. 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!