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

Home » Public Forums » archive » Re: Color problem with contours
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
Re: Color problem with contours [message #67193] Thu, 09 July 2009 06:39
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Robin writes:

> Thank you so much for your help. I've got it all working now, and I
> actually understand what I'm doing (which is always helpful).

This kind of news gets me off to *such* a better start
in the morning! ;-)

Cheers,

David

P.S. Is it unseemly for an older gentleman to skip
to work?

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color problem with contours [message #67194 is a reply to message #67193] Thu, 09 July 2009 06:33 Go to previous message
robintw is currently offline  robintw
Messages: 37
Registered: March 2009
Member
Hi David,

Thank you so much for your help. I've got it all working now, and I
actually understand what I'm doing (which is always helpful).

Thanks again,

Robin
Re: Color problem with contours [message #67209 is a reply to message #67194] Wed, 08 July 2009 07:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Francis Burton writes:

> Does that *still* happen?? Supplementary question: why?

God only knows. My theory is that people like to work
on geegaws that other people use once in a blue moon
more than they like to work on boring stuff that other
people use every day. But, I'm probably wrong. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color problem with contours [message #67210 is a reply to message #67209] Wed, 08 July 2009 07:24 Go to previous message
fburton is currently offline  fburton
Messages: 19
Registered: June 2003
Junior Member
In article <MPG.24be43ef3242fecc98a711@news.giganews.com>,
David Fanning <news@dfanning.com> wrote:
> Whoops! I should have written "undecomposed"
> color. Indexed color on modern computers makes
> me cry so much it is hard to type. :-(

Does that *still* happen?? Supplementary question: why?

Francis
Re: Color problem with contours [message #67214 is a reply to message #67210] Wed, 08 July 2009 05:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Whoops! I mean "decomposed" color.

Whoops! I should have written "undecomposed"
color. Indexed color on modern computers makes
me cry so much it is hard to type. :-(

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color problem with contours [message #67216 is a reply to message #67214] Wed, 08 July 2009 05:42 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Robin writes:

> I'm trying to plot a circular (polar) contour plot using the map
> plotting commands. I've attached my code below. I don't really
> understand much about colours in IDL, but I found that it was being
> displayed as white text on a black background. After a bit of playing
> I found that adding the lines under the comment "Load colors into
> colortable" made it display with a white background and black text.
>
> However, this seems to add an extra line at the bottom of the
> colortable, which means that very low values of my contours plot as
> white (which makes it look as if they're not there, as the background
> is white).
>
> As I said, I don't really quite get IDL colors, even though I've read
> various bits in books about them. I've tried playing with the "bottom"
> keywords to various routines, but that doesn't really seem to help.
> I've also tried playing with FSC_COLOR (which I'm using successfully
> elsewhere in my program), but that just seemed to confuse things
> entirely.

Sigh...

It is always so depressing to wake up and realize that your
life's work, to make IDL colors understandable to normal
people, is still unfinished after nearly twenty years of
work. It almost makes you want to go back to bed, to tell
you the truth.

OK, let me go fix a cup of coffee and I'll walk you through
it again.

> Ideally, what I'd like is to have a white background, with black text
> and lines, and then with the colors for the contours plotting
> correctly. I'm sure this must be possible, but I'm not sure how.

Here is a rule. Don't *ever* violate it or colors will
forever be incomprehensible to you. Do NOT use color
indices 0 or 255 for drawing colors. Ever. I mean it.
In your case, "drawing colors" means the colors you
want to use for your contour plot and black and white.

> PRO MAP_PLOT_DATA, azimuths, zeniths, dns, title
> ; Set positions for drawing the plot and the colourbar
> draw_position = [.10, .07, .80, .90]
> cbar_position = [.85, .07, .88, .90]
>
> ; Set the map projection to orthographic, looking down from the
> north pole
> ; The REVERSE=1 and the third numeric parameter (180) ensure that N,
> E, S and W are at the appropriate locations
> MAP_SET, /ORTHOGRAPHIC, 90, 0, 180, REVERSE=1, /ISOTROPIC,
> title=title, position=draw_position, color=1

In the command above you are using a color before you *load*
the color tables. That command might work once to give you
the right color, but it won't work twice. Here is another
rule: Load your colors BEFORE (and I usually mean JUST BEFORE)
you want to use them. Lord knows what else might be going
on in your programs (or others!) to muck with color tables.
Assume NOTHING!

> ; Load colours into colortable
> device, decomposed=0
> loadct, 13
> TVLCT, 0, 0, 0, 1 ; Drawing colour
> TVLCT, 255, 255, 255, 0 ; Background colour

OK, it's clear you don't know what you are doing with colors
from this, since almost all rules are violated. :-)

You want 100 colors for contouring (I'm reading ahead a couple
of lines). Load those 100 colors somewhere other than in index
0 or 255. How about indices 1 to 100?

LoadCT, 13, NCOLORS=100, BOTTOM=1

You want black and white colors for drawing something. Put
those somewhere--anywhere--other than 0, 255, or 1-100.
Let's put them at indices 253 and 254, just for grins.

TVLCT, 0, 0, 0, 253 ; black
TVLCT, 255, 255, 255, 254 ; white

Now that you have your colors loaded, issue your MAP_SET
command. Alas, there is one problem. No BACKGROUND
keyword for MAP_SET. So if you want a white background
color, you have to fake it out. Also, you want to use
color indices (sigh...), so better put ourselves in
1970s color. Whoops! I mean "decomposed" color.

And, because you are going to want to do this in PostScript
as soon as I turn my back on you here, let's make sure
everything will work there, too.

Device, Decomposed=0
IF (!D.Flags AND 256) NE 0 THEN Erase, Color=254 ; white background
MAP_SET, /ORTHOGRAPHIC, 90, 0, 180, REVERSE=1, /ISOTROPIC, $
title=title, position=draw_position, color=253, /noerase

> ; Calculate 100 levels for the contouring
> range = MAX(dns) - MIN(dns)
> levels = indgen(100) * (range/100)

Nice work here. :-)

> ; Plot the contours from the irregular data
> contour, dns, azimuths, zeniths, /irregular, /overplot,
> levels=levels, /cell_fill, position=draw_position, color=1
>
> ; Plot the grid over the top of the data
> map_grid, /grid, londel=45, latdel=20, color=1,
> position=draw_position
>
> colorbar, /vertical, /right, range=[min(dns), max(dns)],
> position=cbar_position, title="Digital Number", color=1

Oh, dear. OK, there are black and white "drawing" colors,
and "contour" colors, stored at different places in the
color table. The Contour command needs to use both, as
does the Colorbar command. But you haven't even mentioned
the contour colors to either of those two commands.

Here is what we are going to do. "COLOR" is the drawing
color. "C_COLORS" are the contour colors. Do you see
that the contour colors go from 1 to 100?

contour, dns, azimuths, zeniths, /irregular, /overplot, $
levels=levels, /cell_fill, position=draw_position, $
COLOR=253, C_COLORS=Indgen(100)+1

Now the grid:

map_grid, /grid, londel=45, latdel=20, $
position=draw_position, COLOR=253

Now the color bar. Tell it where it should get its 100 colors!

colorbar, /vertical, /right, range=[min(dns), max(dns)], $
position=cbar_position, title="Digital Number", COLOR=253, $
NCOLORS=100, BOTTOM=1

Whew! Done. Much better. :-)

Cheers,

David

P.S. Twenty years of futile effort is available on my web page.
Most of these topics (well, all) have been discussed multiple
times. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: nike clothing,nike shoes,online store,http://www.nbashoe.com air Jordan Shoes,Nike Air Jordans, Air Force Ones,Retro Air Jordan, Bape Hoodies,Bape shoes-Tencent Traveler|Jordan Shoes,Nike Air Jordans, Air Force Ones,Retro Air Jordan, Bape Hoodie
Next Topic: Path to pro files

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

Current Time: Wed Oct 08 20:06:38 PDT 2025

Total time taken to generate the page: 0.24204 seconds