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

Home » Public Forums » archive » White and black colours appearing when selecting colour 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
White and black colours appearing when selecting colour table [message #91961] Wed, 23 September 2015 08:38 Go to next message
liam.steele is currently offline  liam.steele
Messages: 13
Registered: September 2015
Junior Member
I am wanting to draw a certain number of contours, each with a different colour ranging from blue to red. However, when I select the colour table and set the number of colours, I get a random white and black line appearing.

I've included a simple example below, and the resulting image I get can be found here: http://s7.postimg.org/bm8svkbnv/idl.png

I know there is obviously something simple I'm forgetting to do, but I just can't think what it is!

---

window, 0, retain=2
device, decomposed=0

cgloadct, 25, /brewer, /reverse, ncolors=100
ccol = bindgen(100)

plot, [0,1], [0,100], /nodata, $
background=cgcolor('white'), color=cgcolor('black')
for i = 0, 99 do oplot, [0,1], [i,i], color=ccol[i], thick=12

end
Re: White and black colours appearing when selecting colour table [message #91965 is a reply to message #91961] Wed, 23 September 2015 12:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
liam.steele@gmx.co.uk writes:

> I am wanting to draw a certain number of contours, each with a different colour ranging from blue to red. However, when I select the colour table and set the number of colours, I get a random white and black line appearing.
>
> I've included a simple example below, and the resulting image I get can be found here: http://s7.postimg.org/bm8svkbnv/idl.png
>
> I know there is obviously something simple I'm forgetting to do, but I just can't think what it is!

If you really *have* to use indexed color (and there has been no reason
to since, I don't know, the turn of the century, probably), then you are
going to have to load your color table before you try to do anything
that uses those colors.

You would find life SO much easier it you turned color decomposition on
and just used Coyote Library routines to do your plotting. Everything
will just *work* then, without you having to spend any time thinking
about it. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: White and black colours appearing when selecting colour table [message #91969 is a reply to message #91965] Thu, 24 September 2015 02:24 Go to previous messageGo to next message
liam.steele is currently offline  liam.steele
Messages: 13
Registered: September 2015
Junior Member
On Wednesday, 23 September 2015 20:57:41 UTC+1, David Fanning wrote:
> liam.steele@gmx.co.uk writes:
>
>> I am wanting to draw a certain number of contours, each with a different colour ranging from blue to red. However, when I select the colour table and set the number of colours, I get a random white and black line appearing.
>>
>> I've included a simple example below, and the resulting image I get can be found here: http://s7.postimg.org/bm8svkbnv/idl.png
>>
>> I know there is obviously something simple I'm forgetting to do, but I just can't think what it is!
>
> If you really *have* to use indexed color (and there has been no reason
> to since, I don't know, the turn of the century, probably), then you are
> going to have to load your color table before you try to do anything
> that uses those colors.
>
> You would find life SO much easier it you turned color decomposition on
> and just used Coyote Library routines to do your plotting. Everything
> will just *work* then, without you having to spend any time thinking
> about it. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Thanks David.

I have always plotted this way though, and have never noticed a problem before.

In the example I provided, ccol[60] shows as white, and ccol[82] shows as black. So if I choose to use only 59 colours there is no problem, but any more and the white and then black lines show up.

I'm just stumped as to why it won't work. It has device,decomposed=0, has loaded a set number of colours, and has given them an index. Maybe I should just ignore it and do something else, but it's bugging me!
Re: White and black colours appearing when selecting colour table [message #91971 is a reply to message #91969] Thu, 24 September 2015 05:12 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Liam writes:

> I have always plotted this way though, and have never noticed a problem before.
>
> In the example I provided, ccol[60] shows as white, and ccol[82] shows as black. So if I choose to use only 59 colours there is no problem, but any more and the white and then black lines show up.
>
> I'm just stumped as to why it won't work. It has device,decomposed=0, has loaded a set number of colours, and has given them an index. Maybe I should just ignore it and do something else, but it's bugging me!

Those colors are loaded in the color table at the time you call
cgColorbar. Simply load your color table before you make that call. When
you use indexed colors, you can't guarantee your colors are correct,
that the color table hasn't been corrupted, unless you load the colors
immediately before you use them.

Here is an article that might be related:

http://idlcoyote.com/color_tips/lineinct.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: White and black colours appearing when selecting colour table [message #91975 is a reply to message #91971] Thu, 24 September 2015 05:41 Go to previous messageGo to next message
liam.steele is currently offline  liam.steele
Messages: 13
Registered: September 2015
Junior Member
On Thursday, 24 September 2015 13:12:58 UTC+1, David Fanning wrote:
> Liam writes:
>
>> I have always plotted this way though, and have never noticed a problem before.
>>
>> In the example I provided, ccol[60] shows as white, and ccol[82] shows as black. So if I choose to use only 59 colours there is no problem, but any more and the white and then black lines show up.
>>
>> I'm just stumped as to why it won't work. It has device,decomposed=0, has loaded a set number of colours, and has given them an index. Maybe I should just ignore it and do something else, but it's bugging me!
>
> Those colors are loaded in the color table at the time you call
> cgColorbar. Simply load your color table before you make that call. When
> you use indexed colors, you can't guarantee your colors are correct,
> that the color table hasn't been corrupted, unless you load the colors
> immediately before you use them.
>
> Here is an article that might be related:
>
> http://idlcoyote.com/color_tips/lineinct.html
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Aha! Yes, it must have been setting background=cgcolor('white') and color=cgcolor('black') that corrupted the colour table. Putting cgloatct after the call to cgplot has fixed it. Doh!

Thanks for the help. :)
Re: White and black colours appearing when selecting colour table [message #91976 is a reply to message #91975] Thu, 24 September 2015 05:46 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
liam.steele@gmx.co.uk writes:

> Aha! Yes, it must have been setting background=cgcolor('white') and color=cgcolor('black') that corrupted the colour table. Putting cgloatct after the call to cgplot has fixed it. Doh!

Yes, you are getting into trouble because you are only half committed to
Coyote Graphics. Commit fully to decomposed color and to Coyote Graphics
and your color problems will disappear back into the 20th century where
they belong. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: White and black colours appearing when selecting colour table [message #91978 is a reply to message #91976] Thu, 24 September 2015 05:55 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Yes, you are getting into trouble because you are only half committed
to
> Coyote Graphics. Commit fully to decomposed color and to Coyote Graphics
> and your color problems will disappear back into the 20th century where
> they belong. :-)

Truthfully, you don't really have to commit to decomposed color,
although it seems crazy to me not to. Coyote Graphics routines do all
their work in decomposed color, if they can, and they are smart enough
to tolerate indexed color if they have to work with users who learned to
program at their grandfather's knee. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.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: launch a file
Next Topic: Plot

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

Current Time: Wed Oct 08 07:14:11 PDT 2025

Total time taken to generate the page: 0.00657 seconds