Selecting a PostScript Background Color
QUESTION: I can get any background color I like in my PostScript file as long as it's white. Can I choose another background color?
![]()
ANSWER: The !P.BACKGROUND system variable is set to 255 when you make the PostScript device active. But it doesn't matter what color you load into color index 255, you still get a white background on your PostScript plot! In other words, the color you load into index 255 can be used for other things (as a drawing color, for example), but it doesn't affect the background color of the plot.
There is only one way to get a background color different from white in a PostScript file, and that is essentially to draw an image of a single color in the PostScript window. I like to use POLYFILL for this purpose, like this:
TVLCT, [255,0], [0,255], [0,0], !D.TABLE_SIZE-2 greenColor = !D.TABLE_SIZE-1 redColor = !D.TABLE_SIZE-2 POLYFILL, [1,1,0,0,1], [1,0,0,1,1], /NORMAL, COLOR=greenColor PLOT, data, COLOR=redColor, /NOERASE
Another way would be to use the TV command like this:
image = REPLICATE(greenColor, 2, 2) TV, image, XSIZE=!D.X_SIZE, YSIZE=!D.Y_SIZE PLOT, data, COLOR=redColor, /NOERASE
![]()
Copyright © 1996-2001 David W. Fanning
Last Updated 16 October 2001