0
votes

I need to construct a discrete palette color with only a few colors, say:

set palette defined (0 'red', 1 'red', 1 'green',\ 
                     2 'green', 2 'blue', 3 'blue',\
                     3 'yellow', 4 'yellow')

which will be applied a specific number of times to a unique matrix data-file, i.e., by recycling the palette. Suppose the matrix data-file ranges integers data from 0 up to 16. The palette will be applied four times: first, for data in [0:4]; second, for [4:8], third, for [8:12] and fourth, for [12:16]. The final result I expect is a heat map (2D image) with four colors.

I have tried the following palette:

set palette defined ( (k%4==0)'red',   (k%4==1)'red',\
                      (k%4==1)'green', (k%4==2)'green',\
                      (k%4==2)'blue',  (k%4==3)'blue',\
                      (k%4==3)'yellow',(k%4==4)'yellow' )

where 'k' is the element of matrix data-file. My problem is to define 'k'. Of course, it can be done by some coding on the data-file but I will lose original information.

Is there any way to define such "recycling palette"?

1
Can you clarify your question and provide data/example of what you've tried so far? Have a look at stackoverflow.com/help/mcve for reference.Vinicius Placco
@ViniciusPlacco, I have edited my question.D. Maranhao

1 Answers

1
votes

Leave the palette the way you have it and apply the cyclic repeat at the stage of data input. Original command:

set cbrange [0:4]
set view map
splot $data matrix using 1:2:3 with image

Data value filtered to cycle through palette mapped to [0:4]

splot $data matrix using 1:2:(floor($3)%4) with image