Color bars in different colors for some specific values in Gnuplot

后端 未结 2 1051
谎友^
谎友^ 2021-01-14 21:35

I\'m using Gnuplot to generate a histogram but I need to color some of them in another color if the value are over/under a specific value. Eg if value < 10, color the spe

2条回答
  •  余生分开走
    2021-01-14 22:07

    You can use the following gnuplot script:

    set style fill transparent solid 0.5 noborder
    set boxwidth 0.95 relative
    set palette model RGB defined (0 "green", 1 "yellow", 2 "red")
    plot 'path\to\your\file' using 1:2:($2<=10 ? 0 : $2<=20 ? 1 : 2) with boxes palette
    

    The contents of my test file are

    1 4
    2 15
    3 40
    

    and the outcome I get is

    enter image description here

提交回复
热议问题