comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » WIN device color and backgnd reset after set_plot command
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
WIN device color and backgnd reset after set_plot command [message #47071] Sat, 21 January 2006 20:52 Go to next message
guillaume.drolet.1 is currently offline  guillaume.drolet.1
Messages: 20
Registered: July 2005
Junior Member
Dear group of IDL users--

I've been trying to find an answer to this question but unsuccessfully:

In my IDL start up script, I switch the default WIN device background
and color (!d.background & !d.color) to white and black, respectively.
However, when I write a Post Script file (set_plot, 'PS') and then get
back to the WIN device, the device background and color are resetted to
the default values.

Does anyone have any solution or trick for avoiding such a behavior?

Thank you.

Gui
Re: WIN device color and backgnd reset after set_plot command [message #47177 is a reply to message #47071] Thu, 26 January 2006 09:30 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1138288351.728855.205420@g14g2000cwa.googlegroups.com>,
guillaume.drolet.1@ulaval.ca wrote:

> Thanks David for elucidating some of the mysteries of Direct Graphics.
> I guess I'll write wrappers too...
>
> Cheers,
>
> Gui

Liam Gumley has some nice wrapper programs for PS here

http://gumley.com/

Or you can try mine, which are based on Liam's but work slightly differently,
from here

http://idl.tamu.edu/

Either one could be customized.

Ken Bowman
Re: WIN device color and backgnd reset after set_plot command [message #47182 is a reply to message #47071] Thu, 26 January 2006 07:12 Go to previous message
guillaume.drolet.1 is currently offline  guillaume.drolet.1
Messages: 20
Registered: July 2005
Junior Member
Thanks David for elucidating some of the mysteries of Direct Graphics.
I guess I'll write wrappers too...

Cheers,

Gui
Re: WIN device color and backgnd reset after set_plot command [message #47183 is a reply to message #47071] Thu, 26 January 2006 06:21 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paolo Grigis writes:

>> Why? I don't know why.
>
> Maybe to lower the toner consumption rate? It may have been
> implemented after the discovery of scientists printing
> tons of pages featuring white plots on black background,
> giving nightmares to the people in the budget department ;-)

Oh, I understand why they switched *that*. Have you ever
made the mistake of printing a page with a black background?
You can hardly pick the soggy mess up!

No, I was complaining about *always* setting the background
color index to 0 when they switch back, instead of keeping
track of what it was before and switching back to that.
This seems to me to be a simple programming error that has
persisted in IDL almost from the beginning of time.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: WIN device color and backgnd reset after set_plot command [message #47184 is a reply to message #47071] Thu, 26 January 2006 02:33 Go to previous message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
> [...]
>
> Well, this unhappiness is caused by the odd behavior
> of the PostScript device. It switches foreground and
> background colors, then completely ignores the background
> color. ("You can have any background color you like in PostScript
> as long as it is white.") Then, when it switches back, it
> mindlessly sets !P.Color to what had previously been
> !P.Background and sets !P.Background to 0.
>
> Why? I don't know why.

Maybe to lower the toner consumption rate? It may have been
implemented after the discovery of scientists printing
tons of pages featuring white plots on black background,
giving nightmares to the people in the budget department ;-)

Ciao,
Paolo

The gods decreed it at some
> time in the past and that's the way it is. Get used
> to it, is my advice. I think it falls under the
> category of "direct graphics", which I understand to
> read "hopeless". :-)
>
> Knowing this, of course, allows you to work around it.
> Most of us build "wrappers" that allow us to switch
> from our graphics device back to our display device,
> and visa versa. We change the thickness of plots, the
> fonts, and all of the myriad other things we have to
> tweak to work around this creaky system. Here is another
> thing to go in there.
>
> Cheers,
>
> David
>
>
Re: WIN device color and backgnd reset after set_plot command [message #47185 is a reply to message #47071] Thu, 26 January 2006 02:21 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I think it falls under the
> category of "direct graphics", which I understand to
> read "hopeless". :-)

"Hopeless" is too strong a word, and emotionally laden,
to boot. Perhaps "unchanging" is a better choice and
more accurately reflects my understanding of the situation.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: WIN device color and backgnd reset after set_plot command [message #47186 is a reply to message #47071] Thu, 26 January 2006 01:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
guillaume.drolet.1@ulaval.ca writes:

> I edited my startup script like this (as David's suggest):
>
> !p.background = fsc_color('white')
> !p.color = fsc_color('Navy')

Uh, I don't remember any discussion about a
startup script. I was suggesting you do this
before you draw graphics in whatever device
you find yourself in. And *especially* you need
to do it if you switch from a 24-bit device to
an 8-bit device, and back, since colors are
represented differently in those environments.

I personally don't use these system variables
for ANY colors I care about, mostly for this
non-equivalence between devices. I try to load
my color tables *before* I draw graphics, and I
explicitly stay away from color indices 0 and
255, mostly because these are used by !P.Color
and !P.Background in this perverse way you are
discovering. :-)

> But the same thing keep happening when I switch from WIN to PS and then
> to WIN again: the plot background and color previously set in my
> startup script are resetted to IDL defaults (i.e. black background and
> white color, which I don't like).
>
> Since I usually plot long expressions, I don't to have to specify plot
> color and background every time I plot data after coming back PS device
> to WIN device.
>
> Again, any useful advice is welcome.

Well, this unhappiness is caused by the odd behavior
of the PostScript device. It switches foreground and
background colors, then completely ignores the background
color. ("You can have any background color you like in PostScript
as long as it is white.") Then, when it switches back, it
mindlessly sets !P.Color to what had previously been
!P.Background and sets !P.Background to 0.

Why? I don't know why. The gods decreed it at some
time in the past and that's the way it is. Get used
to it, is my advice. I think it falls under the
category of "direct graphics", which I understand to
read "hopeless". :-)

Knowing this, of course, allows you to work around it.
Most of us build "wrappers" that allow us to switch
from our graphics device back to our display device,
and visa versa. We change the thickness of plots, the
fonts, and all of the myriad other things we have to
tweak to work around this creaky system. Here is another
thing to go in there.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Extract a sub-structure from a structure
Next Topic: Swap memory utilization by IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 10:29:45 PDT 2025

Total time taken to generate the page: 1.28122 seconds