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

Home » Public Forums » archive » color table
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
color table [message #8601] Wed, 26 March 1997 00:00 Go to next message
Ye Hong is currently offline  Ye Hong
Messages: 6
Registered: October 1996
Junior Member
Does anyone know why the system variable !d.table_size is changing ?
Is !d.table_size machine-dependent?

I have my own color table which includes 235 colors. When I need color
image, I load it in. It has been working fine until yesterday when I
found only first 90 color were loaded. It took me a while to figure out
that !d.table_size was changed from 256 to 90. After I exited and
re-ran IDL several time, I found !d.table_size was changing although it
was 256 in most cases.

Thanks in advance.



-- Ye
Re: color table [message #8604 is a reply to message #8601] Wed, 26 March 1997 00:00 Go to previous messageGo to next message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
Ye Hong wrote:
>
> Does anyone know why the system variable !d.table_size is changing ?
> Is !d.table_size machine-dependent?

!D.Table_Size represents the number of colors in IDL's internal color
table. It depends on your machine color bit depth (e.g. 8-bit or
24-bit).

> I have my own color table which includes 235 colors. When I need color
> image, I load it in. It has been working fine until yesterday when I
> found only first 90 color were loaded. It took me a while to figure out
> that !d.table_size was changed from 256 to 90. After I exited and
> re-ran IDL several time, I found !d.table_size was changing although it
> was 256 in most cases.

!D.Table_Size isn't set until you open an IDL window for the first
time. Until then, it defaults to 256 (which *doesn't* mean you have 256
colors). I open and delete a small window upon startup (via the idl
startup file) to ensure the system variable actually reflects the number
of available colors. Loadct does this for you when loading a built-in
color table. If you don't want to do this on startup, you could always
add code like:

if !d.name eq 'X' and !d.window eq -1 then begin ;Uninitialized?
;;If so, make a dummy window to determine the # of colors available.
window,/free,/pixmap,xs=4, ys=4
wdelete, !d.window
endif

The more colors being used by other applications (e.g. Netscape), the
fewer IDL can take for itself. Likely, when you only got 90, you were
running some other color hungry app.

To implement your color table, either create it on the fly to fit into
!D.Table_Size (which is fine if it's simple -- see
<http://www.dfanning.com/tips/create_colortable.html>), or store the
r,g,b vectors in a file, read them in, and down-sample by interpolation
to fit. This is essentially what loadct does with the built-in color
tables with a set of commands like:

if nc ne 256 then begin ;Interpolate
p = (lindgen(nc) * 255) / (nc-1)
r = r(p)
g = g(p)
b = b(p)
endif

where nc is the number of colors (defaults to !D.Table_Size) and the
r,g,b vectors are read in from colors1.tbl. You could be more careful
with your interpolation, if, for instance, you had a few colors that you
require to be in your map (e.g. some plotting colors at the bottom
end). You might then set these required colors (n of them,say), and
then interpolate the rest of your colormap onto the remaining
!D.Table_Size-n spots in the palette.

Good Luck,

JD
Re: Color table [message #40413 is a reply to message #8601] Thu, 05 August 2004 06:41 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Tmorri wrote:

> Hi, can anyone create a color table (200 colors) that goes from yellow to
> green to blue to red to white?
> Thanks a lot.
> Tmorri

You could try our tool x_def_colortable

http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase
x_def_colortable_dbase.pro.html

If you want you could try the binary with vm or rt mode http:/
www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl_html/d base/download
x_def_colortable.sav

regards

Reimar

--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: Color table [message #40415 is a reply to message #8601] Thu, 05 August 2004 08:46 Go to previous messageGo to next message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Tmorri" <torrimorri@yahoo.com> wrote in message news:30a2ff5d0dde2057290d4c1a21faa55a@localhost.talkaboutpro gramming.com...
> Hi, can anyone create a color table (200 colors) that goes from yellow to
> green to blue to red to white?
> Thanks a lot.
> Tmorri

Yes, absolutely anyone can.

Cheers,
bob

PS so as not to be %100 smartass,
the r g b colors are:
color[0] = yellow = [255,255,0]
color[64] = green = [0,255,0]
color[ 128] = blue = [ 0, 0,255]
color[192] = red = [255,0,0]
color[255] = white = [255,255,255]
and just ramp the numbers between for each component.
Re: Color table [message #40425 is a reply to message #8601] Wed, 04 August 2004 21:05 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Tmorri writes:

> Hi, can anyone create a color table (200 colors) that goes from yellow to
> green to blue to red to white?

You might find this article interesting:

http://www.dfanning.com/color_tips/create_colortable.html

You would just build your color table in steps, using
the example in the article as a guide.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Color table [message #58176 is a reply to message #8601] Mon, 21 January 2008 07:09 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> me....again...
>
> Everything works out fine for the blue-white-red, even the background
> color and axis colors, as the colortable.
>
> BUT, I am also working with the blue-red color table, defined as
> follows:
>
>
> steps = 256
> scaleFactor = FINDGEN(steps) / (steps - 1)
> ;color scheme by Fanning to go from blue to red
> tvlct,red,green,blue,/get
> ;Red vector: 0 -> 255
> red = 0 + (255 - 0) * scaleFactor
> ; Green vector: 0 -> 0
> green= REPLICATE(0, steps)
> ; Blue vector: 255 -> 0
> blue = 255 + (0 - 255) * scaleFactor
> TVLCT, red, green, blue
> DEVICE, RETAIN=2, DECOMPOSED=0
> Window, Xsize=steps,Ysize=40, Title='Color Table'
> TV, bindgen(steps) # replicate(1B,40)
>
>
>
> This is also working, fine, but again, my background went to blue, as
> do all the symbols, axes and text in the plot. I would like to change
> background (outside of the plot, but in the window) into white, and
> the rest in black. How can this be done? Just changing to another
> colorvalue e.g. 0 to 255, of course doesn't change with this blue-red
> color table...

The best way to avoid changing the background and foreground
colors is to, well, avoid changing them. :-)

They are located at the top and the bottom of the color table.
(Another good reason not to change them is that if you don't your
PostScript output has a fairly good chance of looking like your
display output.)

Try something like this:

steps = 254
scaleFactor = FINDGEN(steps) / (steps - 1)
;color scheme by Fanning to go from blue to red
tvlct,red,green,blue,/get
;Red vector: 0 -> 255
red = 0 + (255 - 0) * scaleFactor
; Green vector: 0 -> 0
green= REPLICATE(0, steps)
; Blue vector: 255 -> 0
blue = 255 + (0 - 255) * scaleFactor
Loadct, 0, /Silent
TVLCT, red, green, blue, 1
DEVICE, RETAIN=2, DECOMPOSED=0
Window, Xsize=steps,Ysize=40, Title='Color Table'
TV, BytScl(bindgen(steps) # replicate(1B,40), Top=253) + 1B
window, 1
plot, findgen(11)

If you have the CINDEX program, you can have a look at
how your color table looks:

IDL> CIndex

You can find the program here:

http://www.dfanning.com/programs/cindex.pro

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 table [message #58180 is a reply to message #8601] Mon, 21 January 2008 04:35 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
me....again...

Everything works out fine for the blue-white-red, even the background
color and axis colors, as the colortable.

BUT, I am also working with the blue-red color table, defined as
follows:


steps = 256
scaleFactor = FINDGEN(steps) / (steps - 1)
;color scheme by Fanning to go from blue to red
tvlct,red,green,blue,/get
;Red vector: 0 -> 255
red = 0 + (255 - 0) * scaleFactor
; Green vector: 0 -> 0
green= REPLICATE(0, steps)
; Blue vector: 255 -> 0
blue = 255 + (0 - 255) * scaleFactor
TVLCT, red, green, blue
DEVICE, RETAIN=2, DECOMPOSED=0
Window, Xsize=steps,Ysize=40, Title='Color Table'
TV, bindgen(steps) # replicate(1B,40)



This is also working, fine, but again, my background went to blue, as
do all the symbols, axes and text in the plot. I would like to change
background (outside of the plot, but in the window) into white, and
the rest in black. How can this be done? Just changing to another
colorvalue e.g. 0 to 255, of course doesn't change with this blue-red
color table...

Thank you!!!
Re: Color table [message #58182 is a reply to message #8601] Mon, 21 January 2008 02:02 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
Thanks to all for the hints.

David, I have used your CTLoad.pro modules which loads nice colors
from blue over white to red. No, just one more question.
How can I change my background color (out of the plot area) back into
white (it is black now).

Thanks!
Re: Color table [message #58186 is a reply to message #8601] Sun, 20 January 2008 09:53 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> I would like to plot a contour line figure, filled with colors.
> Thereby, positive values should be red-shaded filled, negative blue-
> shaded filled, and white shade around the zero.
>
> Now, I have checked the color table in IDL, and none of them seems to
> have this configuration? If possible, I would like to define the
> colors myself in fixed intervals, like [-10,0] = light grey, [0] =
> white, [0,10] = darkgrey,.... [10,20] = light red, ....
>
> Hope somebody can help me with this!

I would do this:

IDL> CTLoad, 1, NCOLORS=128
IDL> CTLoad, 3, /REVERSE, NCOLORS=128, BOTTOM=128

You can find CTLOAD here:

http://www.dfanning.com/programs/ctload.pro

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 table [message #58187 is a reply to message #8601] Sun, 20 January 2008 07:58 Go to previous messageGo to next message
mmiller3 is currently offline  mmiller3
Messages: 81
Registered: January 2002
Member
This is what I use for making tables like you are looking for:

;; Set up a blue=negative, red=positive color scale. The
;; middle of the scale is black:
red = [bytarr(128), 2*bindgen(128)]
green = bytarr(256)
blue = [2*reverse(bindgen(128)), bytarr(128)]
color_table = 0
tvlct, red, green, blue


;; Set up a blue=negative, red=positive color scale. The
;; middle of the scale is white:
H = [replicate(240.0, 128), replicate(360.0, 128)]
S = 2*[reverse(findgen(128)), findgen(128)]/255
V = fltarr(256)+1

tvlct, H, S, V, /hsv
tvlct, R, G, B, /get
red = R
green = G
blue = B
color_table = 0
tvlct, red, green, blue


Mike
Re: Color table [message #58189 is a reply to message #8601] Sat, 19 January 2008 10:39 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jan 19, 6:20 am, WRC2...@gmail.com wrote:
> Dear all,
>
> I would like to plot a contour line figure, filled with colors.
> Thereby, positive values should be red-shaded filled, negative blue-
> shaded filled, and white shade around the zero.
>
> Now, I have checked the color table in IDL, and none of them seems to
> have this configuration? If possible, I would like to define the
> colors myself in fixed intervals, like [-10,0] = light grey, [0] =
> white, [0,10] = darkgrey,.... [10,20] = light red, ....
>
> Hope somebody can help me with this!
>
> Cheers,
> Matthias

http://www.dfanning.com/color_tips/create_colortable.html
Re: Color table [message #58190 is a reply to message #8601] Sat, 19 January 2008 04:27 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
Owwww, maybe I should look on this group first myself...I have found
some comments on how to create a color table from yellow to red over
blue in the middle, so I will try to use this one to create it from
blue to red over white in the middle!!

Cheers!
Re: Color table [message #58274 is a reply to message #8601] Fri, 25 January 2008 05:23 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> mmmm....because of all the trouble, I have rewritten some things to
> plot it as a postscript file.
>
> Now all colors are right, even with a nice white background color!

Whoa! This is surprising. :-)

> Just 1 more thing: There are some really tiny white stripes in my
> plot, like a kind of grid with a regular pattern?? Any idea how i can
> get rid of this???

Load your colors *just* before you draw your plot. Like, the
*instant* before.

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 table [message #58276 is a reply to message #8601] Fri, 25 January 2008 04:47 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
mmmm....because of all the trouble, I have rewritten some things to
plot it as a postscript file.

Now all colors are right, even with a nice white background color!
Just 1 more thing: There are some really tiny white stripes in my
plot, like a kind of grid with a regular pattern?? Any idea how i can
get rid of this???
Re: Color table [message #58281 is a reply to message #8601] Fri, 25 January 2008 02:35 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
On Jan 25, 10:15 am, David Fanning <n...@dfanning.com> wrote:
> WRC2...@gmail.com writes:
>> it seems this is never going to work. I tried this program, after
>> getting the fsc_color function from your website, and now he tells me
>> the following:
>
>> Compiled module: FSC_COLOR.
>> % Attempt to call undefined procedure/function: 'FSC_COLOR'.
>
>> How is this possible? I got the module like I already got many modules
>> from your website, and all worked beforehand...except this one...
>
> You do seem to be running into an extraordinary number
> of strange problems. Have you noticed anyone giving you
> the Evil Eye lately. :-)
>
> Did you save the function to some location on your IDL path?
> IDL has to be able to find it. It looks in the list of directories
> on its !PATH system variable:
>
> IDL> Print, !PATH
>

Yes, of course! I save all my uploaded modules into the lib directory,
and normally, everything works (like I used the cindex.pro,
ctload.pro,...). But this time, the evil eye has taken
over....grrr....I have no idea what is going on?
Re: Color table [message #58282 is a reply to message #8601] Fri, 25 January 2008 01:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> it seems this is never going to work. I tried this program, after
> getting the fsc_color function from your website, and now he tells me
> the following:
>
> Compiled module: FSC_COLOR.
> % Attempt to call undefined procedure/function: 'FSC_COLOR'.
>
> How is this possible? I got the module like I already got many modules
> from your website, and all worked beforehand...except this one...

You do seem to be running into an extraordinary number
of strange problems. Have you noticed anyone giving you
the Evil Eye lately. :-)

Did you save the function to some location on your IDL path?
IDL has to be able to find it. It looks in the list of directories
on its !PATH system variable:

IDL> Print, !PATH

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 table [message #58283 is a reply to message #8601] Fri, 25 January 2008 00:54 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
> PRO testcolor
>
> Device, Decomposed=0, Get_Decomposed=theState
> CTLoad, 1, NCOLORS=127, CLIP=[10, 245]
> CTLoad, 3, NCOLORS=127, BOTTOM=127, CLIP=[10, 245]
> white = FSC_Color('white', 254) ; Background
> black = FSC_Color('black', 255) ; Foreground
> Erase, COLOR=white
> pos = [0.1, 0.1, 0.9, 0.9]
> TVImage, Bytscl(dist(200), top=253), POSITION=pos
> Plot, [0,200], /NODATA, POSITION=pos, /NOERASE, COLOR=black
>
> void = TVREAD(/PNG, Filename='testcolor')
> Device, Decomposed=theState
>
> END

it seems this is never going to work. I tried this program, after
getting the fsc_color function from your website, and now he tells me
the following:

Compiled module: FSC_COLOR.
% Attempt to call undefined procedure/function: 'FSC_COLOR'.

How is this possible? I got the module like I already got many modules
from your website, and all worked beforehand...except this one...
Re: Color table [message #58294 is a reply to message #8601] Thu, 24 January 2008 10:00 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

>
>> OK, can you tell me the results of this command:
>>
>> IDL> Help, /Device
>
> Screen Resolution: 1280x800
> Simultaneously displayable colors: 16777216
> Number of allowed color values: 16777216
> System colors reserved by Windows: 0
> IDL Color Table Entries: 256
> NOTE: this is a TrueColor device
> NOT using Decomposed color
> Graphics Function: 3 (copy)
> Current Font: System, Current TrueType Font: <default>
> Default Backing Store: None.

Well, here is a program. No salmon colors here! :-)

PRO testcolor

Device, Decomposed=0, Get_Decomposed=theState
CTLoad, 1, NCOLORS=127, CLIP=[10, 245]
CTLoad, 3, NCOLORS=127, BOTTOM=127, CLIP=[10, 245]
white = FSC_Color('white', 254) ; Background
black = FSC_Color('black', 255) ; Foreground
Erase, COLOR=white
pos = [0.1, 0.1, 0.9, 0.9]
TVImage, Bytscl(dist(200), top=253), POSITION=pos
Plot, [0,200], /NODATA, POSITION=pos, /NOERASE, COLOR=black

void = TVREAD(/PNG, Filename='testcolor')
Device, Decomposed=theState

END

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color table [message #58295 is a reply to message #8601] Thu, 24 January 2008 09:41 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
> OK, can you tell me the results of this command:
>
> IDL> Help, /Device

Screen Resolution: 1280x800
Simultaneously displayable colors: 16777216
Number of allowed color values: 16777216
System colors reserved by Windows: 0
IDL Color Table Entries: 256
NOTE: this is a TrueColor device
NOT using Decomposed color
Graphics Function: 3 (copy)
Current Font: System, Current TrueType Font: <default>
Default Backing Store: None.
Re: Color table [message #58297 is a reply to message #8601] Thu, 24 January 2008 09:25 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> The plots looks perfect, just this background color seems to be
> untouchable???

OK, can you tell me the results of this command:

IDL> Help, /Device

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color table [message #58298 is a reply to message #8601] Thu, 24 January 2008 09:02 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
On Jan 24, 5:19 pm, David Fanning <n...@dfanning.com> wrote:
> WRC2...@gmail.com writes:
>> I have tried plotting the 9 plots a page into a ps file, but also
>> there many things went wrong, so therefore, I opt to use the window
>> file and write it with write_png. But in there, my background has this
>> salmon color....
>
> Ah, well, have you tried using TVREAD to create your
> PNG file? Lot's of things could be going wrong with
> how this file is created. TVREAD almost always gives
> good results:
>
> http://www.dfanning.com/programs/tvread.pro
>
> See the code there for details.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Hummmm....I really would like to thank you for all the help, but
still I can't get it right. As you suggest, I use TVread to create a
tiff file, which is written to the file, but again, with this salmon
background.

img=tvread(filename=output+'plot',tiff)


The plots looks perfect, just this background color seems to be
untouchable???
Re: Color table [message #58299 is a reply to message #8601] Thu, 24 January 2008 08:19 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> I have tried plotting the 9 plots a page into a ps file, but also
> there many things went wrong, so therefore, I opt to use the window
> file and write it with write_png. But in there, my background has this
> salmon color....

Ah, well, have you tried using TVREAD to create your
PNG file? Lot's of things could be going wrong with
how this file is created. TVREAD almost always gives
good results:

http://www.dfanning.com/programs/tvread.pro

See the code there for details.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Color table [message #58302 is a reply to message #8601] Thu, 24 January 2008 07:17 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
On Jan 24, 2:04 pm, David Fanning <n...@dfanning.com> wrote:

> Changed again where? On the display? In a PS file?

on the display file.

I have tried plotting the 9 plots a page into a ps file, but also
there many things went wrong, so therefore, I opt to use the window
file and write it with write_png. But in there, my background has this
salmon color....
Re: Color table [message #58310 is a reply to message #8601] Thu, 24 January 2008 05:04 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
WRC2008@gmail.com writes:

> Just one more fact (again, as also posted in another topic....). My
> background color changed again.

Changed again where? On the display? In a PS file?

> Although I define the blue-white-red color table just before putting !
> P.BACKGROUND = 128, checking the 128 color with the cindex tool (being
> white!!), I get a salmon color background, and by no means I can
> change it to white. I can change it to all other colors I want (black,
> blue, red,...) but no white....I am getting a bit desperate with the
> colors here, so I hope someone can help me out!!!

The question is not what the background color is just before
you set !P.Background. The question is, what is the background
color just before you draw your background? If you are using
indexed color (extremely likely from your description of things),
then colors can be changed all the time. You have to have
the right colors in the color table at the time you draw
the thing that is suppose to be in those particular colors.

Or, you can use 24-bit color and have all 16.7 million
colors available 24/7. Have you read the several hundred
articles on color management on my web page? :-)

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 table [message #58311 is a reply to message #58176] Thu, 24 January 2008 00:31 Go to previous messageGo to next message
WRC2008 is currently offline  WRC2008
Messages: 14
Registered: September 2007
Junior Member
Just one more fact (again, as also posted in another topic....). My
background color changed again.
Although I define the blue-white-red color table just before putting !
P.BACKGROUND = 128, checking the 128 color with the cindex tool (being
white!!), I get a salmon color background, and by no means I can
change it to white. I can change it to all other colors I want (black,
blue, red,...) but no white....I am getting a bit desperate with the
colors here, so I hope someone can help me out!!!

The 2 defined color schemes, as suggested by David:

; blue - red
ctload, 1, clip=[10,235], ncolors=128
ctload, 3, clip=[10,235], /reverse, ncolors=128, bottom=128

;blue - white - red
CTLoad, 1, NCOLORS=128
CTLoad, 3, /REVERSE, NCOLORS=128, BOTTOM=128

THANKS!
Re: Color Table [message #72178 is a reply to message #8601] Wed, 18 August 2010 05:44 Go to previous messageGo to next message
Nikola is currently offline  Nikola
Messages: 53
Registered: November 2009
Member
The specified values are not equidistant, so the correct solution is:

r= interpol([0,100,120,20,0,50], [0, 28, 46, 89, 153, 255],
findgen(256))
g= interpol([0,30,20,20,200,220], [0, 28, 46, 89, 153, 255],
findgen(256))
b= interpol([0,150,40,255,230,50], [0, 28, 46, 89, 153, 255],
findgen(256))
tvlct,r,g,b

Cheers,
Nikola
Re: Color Table [message #72186 is a reply to message #8601] Tue, 17 August 2010 06:32 Go to previous messageGo to next message
panblosky is currently offline  panblosky
Messages: 17
Registered: May 2005
Junior Member
On 17 ago, 14:42, Wox <s...@nomail.com> wrote:
> On Tue, 17 Aug 2010 03:27:37 -0700 (PDT), Andres <panblo...@gmail.com>
> wrote:
>
>
>
>> Dear all,
>
>> I want to create a color table with the following values:
>
>> index   red   green   blue
>>  0      0       0         0
>> 28   100     30       150
>> 46   120     20       40
>> 89    20     20       255
>> 153    0     200      230
>> 255   50    220       80
>
>> I tried with the xpalette, but when I interpolate, it just gives
>> everything green. Am I doing something wrong? Is there a simple way to
>> do this?
>
>> Thanks!
>
>> Pablo
>
> How about this:
>
> r=congrid([0,100,120,20,0,50],256,/interp)
> g=congrid([0,30,20,20,200,220],256,/interp)
> b=congrid([0,150,40,255,230,50],256,/interp)
> tvlct,r,g,b
> window & tvscl,dist(200)

Thanks!
Re: Color Table [message #72187 is a reply to message #8601] Tue, 17 August 2010 05:42 Go to previous messageGo to next message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Tue, 17 Aug 2010 03:27:37 -0700 (PDT), Andres <panblosky@gmail.com>
wrote:

> Dear all,
>
> I want to create a color table with the following values:
>
> index red green blue
> 0 0 0 0
> 28 100 30 150
> 46 120 20 40
> 89 20 20 255
> 153 0 200 230
> 255 50 220 80
>
> I tried with the xpalette, but when I interpolate, it just gives
> everything green. Am I doing something wrong? Is there a simple way to
> do this?
>
> Thanks!
>
> Pablo


How about this:

r=congrid([0,100,120,20,0,50],256,/interp)
g=congrid([0,30,20,20,200,220],256,/interp)
b=congrid([0,150,40,255,230,50],256,/interp)
tvlct,r,g,b
window & tvscl,dist(200)
Re: Color table [message #81901 is a reply to message #8601] Sat, 10 November 2012 17:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> I have a single variable spread over three years. I wish to give a
different color to each year.
>
> But instead of color I get grey scale. I have the following script.
>
>
> cgLoadCT, 4, NCOLORS=3, CLIP=[16,240]
> bplate=fltarr(18)
> name=strarr(18)
> mont=fltarr(19)
> years=fltarr(19)
> ffiles = FILE_SEARCH('*.txt1')
> for index=0,n_elements( ffiles)-1 do begin
> year=(strsplit(ffiles(index),'.,_',/extract))[0]
> month=(strsplit(ffiles(index),'.,_',/extract))[1]
> name(index)=string(month)
> years(index) = float(year)
> OPENR, lun, ffiles(index), /GET_LUN
> temp=0.0D
> i=0L
> data=strarr(1)
> print,ffiles(index)
> WHILE ~ EOF(lun) DO BEGIN
> readf,lun,data
> temp=float(data) + temp
> i=i+1
> ;print,i,float(data),data
> ENDWHILE
> print,temp/i
> bplate(index)=temp/i
> mont(index)=index
> close,lun
> free_lun,lun
> endfor
>
> colors = Scale_Vector(Findgen(3), 2009, 2011)
>
> elevColors = Value_Locate(colors,years )
> elevColors = StrTrim(Round(Scale_Vector(elevColors, 0, 10)),2)
>
> !X.TICKNAME=name
>
> cgplot,mont,bplate,psym=4,thick=2,xticks=17,yrange=[260,270] ,xtitle='MONTHS',ytitle='MIN_0_87_MICRON_DETECTOR_TEMP',BACK GROUND = 255, COLOR = 0
> FOR j=0,n_elements(mont)-2 DO cgPlotS, mont[j], bplate[j], Color=elevColors[j], Thick=2,psym=sym(5),symsize = 1.15
> fname="bplate.gif"
> result = cgSnapshot(FILENAME=fname,/gif ,/nodialog)

Uh, well, I think I would just do something like this:

elevColors = ['red', 'green', 'blue']

> Question .2 . Is it possible to view the exact colors Vs color number that are finally loaded by the color table.

Try CIndex:

IDL> cindex

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Plotting a compass
Next Topic: Using self reference in WHERE statement?

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

Current Time: Wed Oct 08 15:12:34 PDT 2025

Total time taken to generate the page: 0.01002 seconds