kitt
kitt

Reputation: 120

plot matrix non-numeric points in different colors using gnuplot

I have a file 'matrix.dat' looks like this:

10584 179888 115816 16768 91440 79928 50656 23624 21712 51776 89670 21815 13536 18984 11997 16221 10336 432 632 2024 - - - - - - - - - - - - - 408 - - - - - - - - - - - - - - - B - - - B - - B - - - - - - - - - - - - 3672 - - 4480 - - - - - - - - 17600 11632 1008 4384 144 - 216 72 - - - - - 768 336 - 384 - - 408 5312 - - - 72 3648 - - - - - - - - - - - - 1088 - - 224 - - - - - - - - - - - 1696 2040 2664 216 - B 344 - - - - - 336 296 248 88 88 616 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2840 - - 128 16 - 112 - - - - - 1904 2776 24 B

I want to plot numbers using palette, '-' using white color and 'B' using black color.
In gnuplot, I use log2 palette (blue -> cyan -> green -> orange -> red) and set '-' as missing data:

set palette model HSV functions 0.666*(1-gray), 1, 1
set logscale cb 2
set datafile missing "-"
plot 'matrix.dat' matrix with image

Now I can only plot numbers and '-' in desired colors. How can I plot 'B' in black color?

Upvotes: 2

Views: 348

Answers (1)

kitt
kitt

Reputation: 120

I solved the problem using a piecewise function. Just a small change:

set palette model HSV functions gray>0 ? 0.666*(1-gray):0, 1, gray>0 ? 1:0

then change all 'B' of the file into '0'. The idea is that using black color for 0 and using colors in palette for non-zero values. Thanks!

Upvotes: 2

Related Questions