Gnuplot change color of bars in histogram

后端 未结 4 1198
遥遥无期
遥遥无期 2020-12-25 15:19

is it possible to change the color of bars in a Gnuplot script dynamically? I have the following script

reset
fontsize = 12
set term postscript enhanced eps         


        
4条回答
  •  情书的邮戳
    2020-12-25 15:58

    You can mimic this behavior using the boxes style:

    My test data:

    zip 2
    baz 2
    bar -1
    cat 4
    foo -3
    

    And then plotting with gnuplot:

    set style line 1 lt 1 lc rgb "green"
    set style line 2 lt 1 lc rgb "red"
    set style fill solid
    plot 'test.dat'  u (column(0)):2:(0.5):($2>0?1:2):xtic(1) w boxes lc variable
    #                  #xval:ydata:boxwidth:color_index:xtic_labels
    

提交回复
热议问题