I have the following sample data:
col1 2 0 1 1
col2 1 1 0 0
col3 1 1 1 0
col4 1 1 2 1
col5 1 1 1 1
col6 2 0 1 1
col7 1 1 2 2
col8 1 1 2 1
columns #4 and #5 are the color codes for columns #2 and #3. For example, I want '1' for green, 2 for white, and 0 for orange.
Here is how I tried to plot it:
set key off
unset border
unset xtics
unset ytics
set style data histograms
set style histogram rowstacked
set boxwidth 1 relative
set style fill solid 1.0 border -1
set yrange [0:2]
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0.1
set terminal pngcairo truecolor size 100,65
set output "/export/test.png"
set palette model RGB defined ( 0 'orange', 1 'green', 2 'white')
plot 'test.data' u 2 linecolor rgb "orange", '' u 3 linecolor rgb "green"
Here is what I got without being able to implement the color according to the actual data:
So how do I use the actual colors as specified in my data file?
[in case anybody wonders and in case the rational behind this encourages your efforts;-): I am trying to draw an HP blade c7000 chassis, using color coding to show empty chassis slots, slots with blades that are powered on and off. The actual values in column #2 and #3 indicate whether the blade is full-height (with value of 2) or half-height blades (with a value of 1). Where there is no blade, it still gets a value of 1, defaulting to half-height.]
## UpdateWith this, I was able to get what I need...Anybody has a shorter version?
plot 'test.data' u ($5==0?$2:sqrt(-1)) linecolor rgb "orange",\
'' u ($5==1?$2:sqrt(-1)) linecolor rgb "green",\
'' u ($5==2?$2:sqrt(-1)) linecolor rgb "white",\
'' u ($4==0?$3:sqrt(-1)) linecolor rgb "orange",\
'' u ($4==1?$3:sqrt(-1)) linecolor rgb "green",\
'' u ($4==2?$3:sqrt(-1)) linecolor rgb "white"
Further refinement
How do I add numbering to the blocks as the following image shows:
Updated Question:
I noticed that sometimes the color pallete gets the color wrong, unless all colors defined in the pallete are present in the data. For example, with the following data:
1 2 0 1 1
2 1 1 0 0
3 2 0 1 1
4 2 0 1 1
5 1 1 1 1
6 1 1 1 0
7 1 1 1 1
8 1 1 1 1
As you can see from col#4-5, I have only 'green' (1) and 'organge' (0). As I don't have any slot empty, I don't have 'white' color. I get this image:
This image obviously is incorrect, as white would indicate that I have an empty slot. I expected this image:
So how did the colors 'white' and 'green' get flipped? I noticed if I change any one of those color code to white, then the color pallete will work correctly.