Graphics windows and color: {Gumley 5.3, 5.4} Windows: IDL> x=FINDGEN(360)*!DTOR IDL> y=SIN(x) IDL> PLOT,x,y ; opens a window if none already open. IDL> WINDOW,1 ; opens a new window with index 1 IDL> PLOT,x,y ; and makes it the active window. IDL> WSET,0 ; makes window 0 the active window. IDL> PRINT,!D.WINDOW ; !D.WINDOW is the index of the IDL> PLOT,x,y ; active window. IDL> WINDOW,2,RETAIN=2 ; on some computers it is necessary to IDL> PLOT,x,y ; add RETAIN=2 so a window in not erased ; when another is placed or moved over it. IDL> WINDOW,3,XSIZE=1000,YSIZE=500 ; sizes in pixels. IDL> PLOT,x,y IDL> WDELETE,0 ; closes window 0. ; or you can just close it with the mouse. Colors: Computers use 8, 16, or 24 bit color. IDL uses either 8 or 24 bit color and the rgb (red, green, blue) format. Each r, g, b is 8 bits (1 byte), which can represent an integer from 0 to 255, i.e., 256=2^8 different values for each of the three basic colors: r = 0 to 255, g = 0 to 255, b = 0 to 255. Two different modes: DECOMPOSED=1 (i.e., TRUE) or DECOMPOSED=0 (i.e., FALSE) DECOMPOSED=1: (decomposed color) 2^24 = 16 million different color choices = 256^3 i.e, 256 choices of red 256 choices of green 256 choices of blue That is, it takes 3 bytes to specify one color. DECOMPOSED=0: (indexed color) a color table with 256 color choices, indexed from 0 to 255. That is, it takes 1 byte to specify one color. index R G B 0 x x x 1 x x x 2 x x x . . . 255 x x x The default mode is DECOMPOSED=1 if computer has 24 bit color. IDL> DEVICE, GET_VISUAL_DEPTH=d1, GET_DECOMPOSED=d2 IDL> PRINT,d1,d2 The visual depth (d1) will be either 8 or 24 (on our suns) - we want 24. If it's 8, here's how to change it to 24 on your terminal. At the unix prompt (not in IDL), type: m64config -res 1024x768x60 -depth 24 and then logoff your computer and then log back on and then (in IDL) check the GET_VISUAL_DEPTH again to make sure it's now 24. If you want indexed color (which is what we will use) then do IDL> DEVICE, DECOMPOSED=0. If you use indexed color commands without first setting DECOMPOSED=0, then your plots will have only shades of red. IDL> XLOADCT ; this displays the 39 IDL color tables IDL> XPALETTE ; this provides more information about the color table IDL> TVLCT,r,g,b,/GET ; this gets the current color table and stores it in ; output arrays r, g, b. IDL> HELP,r ; note, here r, g and b are arrays, ; each with 256 elements, each element being 1 byte. IDL> PRINT,r IDL> PRINT,g IDL> PRINT,b IDL> LOADCT ; this lists the available IDL color tables and ; their numbers and loads the color table you select. IDL> LOADCT,33 ; this loads IDL color table 33. IDL> TVLCT,r,g,b,/GET IDL> PRINT,r IDL> PRINT,g IDL> PRINT,b When plotting, the default background color index is 0 and the default line color index is 255. For example, for the IDL color table number 0 (the default black and white one) the first color (index 0) has r=0, g=0 and b=0, which is black and the last color (index 255) has r=255, g=255 and b=255, which is white. IDL> x=FINDGEN(360)*!DTOR IDL> y=SIN(x) IDL> PLOT,x,y,COLOR=135,BACKGROUND=247 Try loading different color tables (using LOADCT, table_number) and then doing the PLOT command again but with different values for the COLOR and BACKGROUND keywords. You can see the colors in the table you select by using XPALETTE or XLOADCT. IDL> d=DIST(100,100) IDL> SHADE_SURF,d,SHADES=BYTSCL(d) ; this works like SURFACE ; but plots a solid surface and ; colors it according to ; the values of d. ; that is, BYTSCL scales the ; floating point array, d, to ; byte values between 0 and 255. IDL> LOADCT,3 ; change the color table. IDL> SHADE_SURF,d,SHADES=BYTSCL(d) You can make your own color tables - here is an example: IDL> r=BYTE(INDGEN(256)) IDL> g=BYTE(0)*r IDL> b=BYTE(255)-r IDL> PRINT,r IDL> PRINT,g IDL> PRINT,b IDL> TVLCT,r,g,b ; note, now without the keyward /GET ; and so r,g,b are now input arrays. IDL> SHADE_SURF,d,SHADES=BYTSCL(d) IDL> TVLCT,b,g,r ; note, reversing r and b IDL> SHADE_SURF,d,SHADES=BYTSCL(d)