'How to plot histogram with color function of a column value?

I Would like to plot a histogram but the color of my boxes should be function of a value inside a column. If the value in column 12 of my file is egal to 160 the color change in red.

my script :

set xlabel 'elapsed' font ",14"
set ylabel 'NCPUS' font ",14"
set xtics font "Verdana,12"
set style fill solid border -1
set xtic rotate by -45 scale 0


color(x)=(x==160?1:2)
#p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with histogram notitle ls color(12)


p "< sort 'histo' -k10n" using 12:xticlabels(($10)/3600) with boxes notitle ls color(12)

What I get :

enter image description here

my data :

     User        JobID    JobName  Partition      State  Timelimit               Start                 End    Elapsed ElapsedRaw   NNodes      NCPUS        NodeList 
--------- ------------ ---------- ---------- ---------- ---------- ------------------- ------------------- ---------- ---------- -------- ---------- --------------- 
  bouchet 6389               E423       epic  COMPLETED 365-00:00+ 2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59     312719        5        160        lio[1-5] 
          6389.batch        batch             COMPLETED            2022-02-28T20:32:49 2022-03-04T11:24:48 3-14:51:59     312719        1         32            lio1 
  bouchet 6393               Fenc       epic  COMPLETED  UNLIMITED 2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53     104573        5        160        lio[1-5] 
          6393.batch        batch             COMPLETED            2022-03-04T12:08:07 2022-03-05T17:11:00 1-05:02:53     104573        1         32            lio1 
  bouchet 6399               Fenc       epic  COMPLETED  UNLIMITED 2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58     233758        5        160        lio[1-5] 
          6399.batch        batch             COMPLETED            2022-03-05T17:11:12 2022-03-08T10:07:10 2-16:55:58     233758        1         32            lio1 

and when I use lc rgb variable I get :

boucher.plot", line 12: Not enough columns for variable color

Any ideas please ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source