[GRASS-dev] Background Colours

Paul Kelly paul-grass at stjohnspoint.co.uk
Wed May 16 11:56:56 EDT 2007

On Wed, 16 May 2007, Michael Barton wrote:

> Maybe a stupid question, but can you give a histogram a blue or green
> background? Changing certain functions give all PNG output a black
> background, regardless of colors assigned. So it's possible that you still
> aren't able to change the color of the histogram. Giving it something other
> than white or black would definitely show that it's possible.

Actually, good question. It appears I was a little hasty with my 
assumption of how it was working. On further investigation, it seems 
$GRASS_BACKGROUNDCOLOR is totally irrelevant if $GRASS_TRANSPARENT is set 
to true (because, obviously, the part that is background is transparent). 
So all the colour comes from the g.pnmcomp step. And it must have been 
black there because that is the default if the "background=" option is not 
specified. So the way to get a different coloured background is to put the 
desired background colour into the "background" field at the g.pnmcomp 
step, and make sure $GRASS_TRANSPARENT is true. And $GRASS_BACKGROUNDCOLOR 
is actually irrelevant when using transparency, it would seem.

(Of course this discussion assumes the change is also made to d.histogram 
not to erase the frame before it starts drawing. If it does erase it will 
pick up the hard-coded (in include/gis.h) GRASS_BG_COLOR which is white; 
in effect the whole frame will be filled with this colour and it will no 
longer be transparent..):

>> * Changing D_setup(1); to D_setup(0); in display/d.histogram/main.c

Actually in light of this I don't see any reason why not to change 
d.histogram back to the old behaviour. The worst that can happen is the 
histogram is drawn over a map already in a display, but all that needs 
done then is d.erase or d.frame -e and repeat the d.histogram command. But 
the big gain is a histogram plot with a transparent background. I'll make 
the change some time before too long if nobody objects. Or we could add a 
new flag that doesn't erase and always run it from the GUI with that flag 
set. I prefer the simplicity of just changing it back though (and thus 
restoring its behaviour to be in accordance with the man page).


More information about the grass-dev mailing list