Each pixel on the screen is made up of three colours: red, green and blue, each of which is represented by one byte and can therefore take on values between 0 (black) and 255 (as bright as possible). There are therefore 256 cubed = 16777216 possible colours.
Some monitors (hopefully all of the ones you will use) have three bytes ( 24 bits ) of video memory for each pixel - on such a monitor you can make any pixel any one of these 16777216 colours any time you like. A few older monitors may have only one byte of video memory per pixel, which means that there are only 256 colours available. You can make a pixel any of the 16777216 possible colours BUT you can only have 256 of those colours on the screen at any one time. Hopefully you wont encounter one of these. However as a result of this history, a lot of colour management in IDL is done via tables of (up to) 256 colours.
To use a 256 element colour table, such as those built in to IDL use
device,true_color=24,decomposed=0,retain=2at the start of your idl session. I have put this line in a procedure all by itself, which I run at the start of almost every IDL session.
e.g. Start IDL then,
device,true_color=24,decomposed=0,retain=2 ;NEW LINE window,0,retain=2 ;load colour table 39 - rainbow+white loadct,39 ;get r,g,b the intenisties of red green and ble for each of the 256 colours tvlct,r,g,b,/get plot,r,xtitle='Index',ytitle='Intensity',background=255,color=0 oplot,r,color=230 oplot,g,color=150 oplot,b,color=50 oplot,[0,0],[0,0],color=0,psym=3 write_png,'~lecjm/filename.png',tvrd(true=1),r,g,b
This makes the plot look right on the screen and right in the file. I have defined a procedure set_col.pro that just calls the line:
device,true_color=24,decomposed=0,retain=2 ;NEW LINEsince I use it so much.
For postscript,
set_plot,'ps' device,file='~lecjm/filename.ps',/color loadct,39 tvlct,r,g,b,/get plot,r,xtitle='Index',ytitle='Intensity' oplot,r,color=230 oplot,g,color=150 oplot,b,color=50 oplot,[0,0],[0,0],color=0,psym=3 device,/close