Reputation: 16711
I want to plot m*n
matrix, each element of which is an rgb
triple, like in the following gnuplot code snippet (rgb matrix of 3*3
):
$cross << EODcross
255 0 0 0 0 0 255 0 0
0 0 0 0 0 0 0 0 0
255 0 0 0 0 0 255 0 0
EODcross
Black cross on red background. I can change delimiters between columns and color components, if needed.
Can I achieve the desired avoiding set palette rgbformulae i,j,k
and directly using $cross
data? Something like:
plot '$cross' matrix with image rgb
If not, I can pass 24bit-wide integers (of course, in textual representation, i.e. precalculated and converted to text r + 256 * (g + 256 * b)
or b + 256 * (g + 256 * r)
value). How should i,j,k
triple looks like to correctly map rgb
value represented in mentioned form to palette color space?
Upvotes: 4
Views: 978
Reputation: 48390
The rgbimage
plotting style expects five columns, the last three give red, blue and green values in the range [0:255]. So you can use any 24-bit integer representation of the colors, because you must extract the color channels yourself when plotting:
$data <<EOD
0xff 0 0xff00
0 0 0
0xffff 0 0xff00ff
EOD
r(x) = int(x) >> 16
g(x) = (int(x) >> 8) & 0xff
b(x) = int(x) & 0xff
plot $data matrix using 1:2:(r($3)):(g($3)):(b($3)) with rgbimage
Upvotes: 4
Reputation: 4218
It seems that ascii matrix data and rgbimage do not fit together.
If you are free to format your input data, then put each column of the image into a single block, separating the blocks by two blank lines like this:
$cross << EODcross
255 0 0
0 0 0
255 0 0
0 0 0
0 0 0
0 0 0
255 0 0
0 0 0
255 0 0
EODcross
Then plot the cross like this:
plot $cross using -2:0:1:2:3 with rgbimage
The numbers -2 and 0 in the using
section correspond to the pseudo columns "block index" and "line within a block", respectively. They are used as x and y values. The plot with rgbimage
style requires x,y,r,g,b
data.
This is the result:
Upvotes: 2