#pick the red color value out
red(rgbvalue)=rgbvalue/65536
#pick the green color value out
green(rgbvalue)=(rgbvalue%65536)/256
#pick the blue color value out
blue(rgbvalue)=rgbvalue%256
#convert dec color value to its hex string
dec2hex(dec)=gprintf("%02x",dec)
#convert rgb color value to its hex string
rgb2hex(color)="#".\
dec2hex(red(color)).\
dec2hex(green(color)).\
dec2hex(blue(color))
color = 65535 #rgb-value
print "The hex string of rgb-color ". color ." is: "
print rgb2hex(color)
plot cos(x) w line linecolor rgb rgb2hex(color)
Run this script, it will output the following string and picture.
The hex string of rgb color 65535 is: #00ffff
![]() |
| Fig.1 Converting from a rgb color specification to its hex-string |

Very helpfull. Greetings from Portugal.
ReplyDeleteNice article. It's very helpful to me. Thank you for share with us. Can you please check my hexadecimal color codes online tool.
ReplyDeleteI have found that this site is very informative, interesting and very well written. keep up the nice high quality writing. Dried Whole Shrooms
ReplyDeleteThis article presents a clear and practical explanation of converting RGB color values into their corresponding hexadecimal format, which is especially useful for visualization tools like gnuplot and other plotting environments. The step-by-step breakdown helps bridge the gap between raw numerical color definitions and widely used hex notation, making it easier for users to apply consistent and accurate color styling in their graphs and visual outputs. Overall, it’s a concise and valuable reference for anyone working with color manipulation in programming or data visualization, particularly where precision and reproducibility of colors are important.
ReplyDeleteBuilders Cleaning Perth
dack s