问题
Reading this and this answer I understood that changing the colours of every point is possible, but:
it has to be defined using
set palette model RGB defined ()
, hence if I want 100 different colours I will have to define all of themthe colour of the point is specified just before it is drawn.
My question is, is there a way to avoid all of the above, for example modify my data file as follows:
x y z R G B
1 2 3 0 255 255
5 6 2 255 0 0
And have the according point drawn with the specified colour?
回答1:
Try the following on gnuplot 4.6+:
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
plot "data.dat" using 1:2:(rgb($3,$4,$5)) with points lc rgb variable
From the manual:
1.17.1.3 rgbcolor variable
variable tells the program to read RGB color information for each line in the data file. This requires a corresponding additional column in the using specifier. The extra column is interpreted as a 24-bit packed RGB triple. If the value is provided directly in the data file it is easiest to give it as a hexidecimal value (see 'rgbcolor'). Alternatively, the using specifier can contain an expression that evaluates to a 24-bit RGB color as in the example below. Text colors are similarly set using tc rgbcolor variable.
来源:https://stackoverflow.com/questions/26539305/how-to-add-colors-to-every-point-in-gnuplot-from-inside-the-point-file