How to plot matrix with rgb image?

核能气质少年 提交于 2019-12-06 04:16:06

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

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:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!