|
Re: How to create a colour table in IDL? [message #89983 is a reply to message #89982] |
Tue, 13 January 2015 02:39   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
this is not my stuff, but I tied this and it worked:
loadct, 70
window, xsize=600, ysize=600
cgimage, dist(600)
or, even easier:
window, xsize=600, ysize=600
cgimage, dist(600), ctindex=70
regards,
Helder
On Tuesday, January 13, 2015 at 11:32:20 AM UTC+1, Madhavan Bomidi wrote:
> Hello,
>
> I have gone through the previous posts on this topic, but I could not understand how I can create a colour table in IDL. I am interested in using the colour table with only blue and red colours similar to XLOADCT: 70 - CB-RdBu - (as shown in http://www.exelisvis.de/docs/loadingdefaultcolortables.html). Can any one tell me how I can use the 'XLoadCT' colour table 70 with 'loadCT' command?
>
> Look forward for a favourable response,
>
> Thanking you,
> With regards,
> Madhavan
|
|
|
Re: How to create a colour table in IDL? [message #89984 is a reply to message #89983] |
Tue, 13 January 2015 02:54   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Just in case you don't want to use David's library, then you have to make sure that decomposed is off:
device, decomposed=0
window, xsize=300, ysize=300
tv, dist(300)
To check for your current decomposition state, use:
If "decomposed" stuff is not your thing, I would recommend to do the following:
device, get_decomposed=current_decomp_Value
print, 'my current decomposed value is ', current_decomp_Value
device, decomposed=0
;do you calculations/imaging here
;restore the previous decomposition state:
device, decomposed=current_decomp_Value
If you're not sure what decomposed means and does, used David's libary or read his books (the second option gives you more than the first).
Regards,
Helder
|
|
|
Re: How to create a colour table in IDL? [message #89985 is a reply to message #89984] |
Tue, 13 January 2015 03:46   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello Helder,
Thanks for your response but it doesn't work.
I use the following lines in the code:
--------------------------------------------------------
device, decomposed=1
LoadCT, 70
mg_horizon,indgen(4600),randomn(seed,12,4600),nbands=6, xstyle=1, ystyle=1
--------------------------------------------------------
I get the following error:
% LOADCT: Table number must be from 0 to 40
Note: You can download mg_horizon.pro from https://github.com/mgalloy/mglib/tree/master/src/vis/lineplo ts
Can anyone help me how I can use the colour table XLOADCT: 70 - CB-RdBu - (shown in http://www.exelisvis.de/docs/loadingdefaultcolortables.html)?
Thanking you once again,
With regards,
Madhavan
On Tuesday, January 13, 2015 at 11:54:12 AM UTC+1, Helder wrote:
> Just in case you don't want to use David's library, then you have to make sure that decomposed is off:
>
> device, decomposed=0
> window, xsize=300, ysize=300
> tv, dist(300)
>
> To check for your current decomposition state, use:
> If "decomposed" stuff is not your thing, I would recommend to do the following:
> device, get_decomposed=current_decomp_Value
> print, 'my current decomposed value is ', current_decomp_Value
>
> device, decomposed=0
> ;do you calculations/imaging here
>
> ;restore the previous decomposition state:
> device, decomposed=current_decomp_Value
>
> If you're not sure what decomposed means and does, used David's libary or read his books (the second option gives you more than the first).
>
> Regards,
> Helder
|
|
|
Re: How to create a colour table in IDL? [message #89986 is a reply to message #89985] |
Tue, 13 January 2015 04:28   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, January 13, 2015 at 12:46:10 PM UTC+1, Madhavan Bomidi wrote:
> Hello Helder,
>
> Thanks for your response but it doesn't work.
>
> I use the following lines in the code:
> --------------------------------------------------------
> device, decomposed=1
> LoadCT, 70
>
> mg_horizon,indgen(4600),randomn(seed,12,4600),nbands=6, xstyle=1, ystyle=1
> --------------------------------------------------------
>
> I get the following error:
> % LOADCT: Table number must be from 0 to 40
>
> Note: You can download mg_horizon.pro from https://github.com/mgalloy/mglib/tree/master/src/vis/lineplo ts
>
> Can anyone help me how I can use the colour table XLOADCT: 70 - CB-RdBu - (shown in http://www.exelisvis.de/docs/loadingdefaultcolortables.html)?
>
> Thanking you once again,
> With regards,
> Madhavan
>
> On Tuesday, January 13, 2015 at 11:54:12 AM UTC+1, Helder wrote:
>> Just in case you don't want to use David's library, then you have to make sure that decomposed is off:
>>
>> device, decomposed=0
>> window, xsize=300, ysize=300
>> tv, dist(300)
>>
>> To check for your current decomposition state, use:
>> If "decomposed" stuff is not your thing, I would recommend to do the following:
>> device, get_decomposed=current_decomp_Value
>> print, 'my current decomposed value is ', current_decomp_Value
>>
>> device, decomposed=0
>> ;do you calculations/imaging here
>>
>> ;restore the previous decomposition state:
>> device, decomposed=current_decomp_Value
>>
>> If you're not sure what decomposed means and does, used David's libary or read his books (the second option gives you more than the first).
>>
>> Regards,
>> Helder
Maybe you have an older version of IDL? I could not find if the tables have been updated somewhen along the history of IDL.
If you use
loadct, GET_NAMES=names
print, names
you get a list of available paletts.
good luck.
h
|
|
|
|
Re: How to create a colour table in IDL? [message #89988 is a reply to message #89987] |
Tue, 13 January 2015 05:33   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Thank you David. It works!!!
On Tuesday, January 13, 2015 at 1:56:03 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>> I have gone through the previous posts on this topic, but I could not understand how I can create a colour table in IDL. I am interested in using the colour table with only blue and red colours similar to XLOADCT: 70 - CB-RdBu - (as shown in http://www.exelisvis.de/docs/loadingdefaultcolortables.html). Can any one tell me how I can use the 'XLoadCT' colour table 70 with 'loadCT' command?
>
> cgLoadCT, 22, /Brewer
>
> 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: How to create a colour table in IDL? [message #90004 is a reply to message #90003] |
Wed, 14 January 2015 10:09   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello David,
There is no change in the colorbar in both the following cases:
cgLoadCT, 22, /Brewer
(or)
cgLoadCT, 22, /Brewer, ncolors=6
I wanted to have 6 color bands from /Brewer colour table similar to the one shown in the link indicted earlier. I don't understand where I am going wrong?
Thanks in advance,
Madhavan
On Wednesday, January 14, 2015 at 6:39:22 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>> I have seen online links but I could not understand how to extract specific colours from /BREWER colour table similar to the colorbar shown at http://latticeextra.r-forge.r-project.org/#horizonplot
>>
>> I require to extract 6 colours from /BREWER colour table to represent the contrast in the figure. How can I know the colour indices or colour names in /BREWER colour table? May be my terminology is wrong!!!
>>
>> Can you please suggest me how I can do this?
>
> cgLoadCT, 22, /Brewer, NCOLORS=6
>
> 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: How to create a colour table in IDL? [message #90005 is a reply to message #90004] |
Wed, 14 January 2015 10:16   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Madhavan Bomidi writes:
> There is no change in the colorbar in both the following cases:
>
> cgLoadCT, 22, /Brewer
> (or)
> cgLoadCT, 22, /Brewer, ncolors=6
>
> I wanted to have 6 color bands from /Brewer colour table similar to the one shown in the link indicted earlier. I don't understand where I am going wrong?
I think you probably are NOT reading the documentation. :-)
There is a HUGE difference. Type these commands:
cgLoadCT, 22, /Brewer
cIndex
Now, close cIndex and type these commands:
cgLoadCT, 0
cgLoadCT, 22, /Brewer, NColors=6
cIndex
Do you see the difference?
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: How to create a colour table in IDL? [message #90016 is a reply to message #90005] |
Thu, 15 January 2015 02:40   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello David,
Yes. I can see the difference. But when I incorporate the same into my code, I don't see any difference. May be something going wrong which I could not trace!!!
Will it be possible for you to check where I am going wrong in my code?
Below is my code:
---------------------------------
PRO testplot
tindex = indgen(1000)
d = randomu(1L, 12, 1000)
minval = MIN(d,MAX=maxval)
FigFile = 'testplot1.ps'
cgPS_Open, FigFile
cgDisplay
thick = (!D.Name EQ 'PS') ? 2:1
!P.Multi=0
device, decomposed=0
cgLoadCT, 0
cgLoadCT, 22, /Brewer
tvlct, 0, 0, 0, 0
tvlct, 255, 255, 255, 255
cgColorbar, /Brewer, CTindex=22, TCharsize=0.12, $
range=[minval,maxval],/right, tlocation='right', $
Title='d',/Vertical, Font=-1, Minor=5, $
Position=[0.81,0.32,0.83,0.90]
mg_horizon, tindex, d, nbands=6,titles=ytitles, $
xstyle=1, ystyle=1, Xrange=[0,1000], $
Thick=thick, Font=-1, minimum=minval, $
maximum=maxval, Position=[0.1,0.3,0.70,0.94]
; Closing the figure file
cgPS_Close
; Create a PNG file
cgPS2Raster, FigFile, /PNG
END
--------------------------------------
|
|
|
|
Re: How to create a colour table in IDL? [message #90022 is a reply to message #90016] |
Thu, 15 January 2015 06:06   |
Burch
Messages: 28 Registered: December 2013
|
Junior Member |
|
|
> cgLoadCT, 22, /Brewer
> tvlct, 0, 0, 0, 0
> tvlct, 255, 255, 255, 255
>
> cgColorbar, /Brewer, CTindex=22, TCharsize=0.12, $
> range=[minval,maxval],/right, tlocation='right', $
> Title='d',/Vertical, Font=-1, Minor=5, $
> Position=[0.81,0.32,0.83,0.90]
Firstly, you need to add NCOLORS = 6 to both cgLoadCT and cgColorbar, Secondly, don't use the BREWER and CTINDEX keywords when you call cgColorbar; you have already loaded the color table you want. See the difference between
cgLoadCT, 22, /brewer, nColors = 6
cgColorbar, nColors = 6
and
cgLoadCT, 22, /brewer, nColors = 6
cgColorbar, /brewer, ctIndex = 22, nColors = 6
The last one does not use the color table you have loaded with cgLoadCT. Also note that when you do
tvlct, 0, 0, 0, 0
you are overwriting the first element of the color table. Therefore, black becomes one of the six colors you are using. If this is not the desired behavior, then perhaps you should place this outside the first six elements. I suggest using cIndex to look at what this does to your color table.
|
|
|
Re: How to create a colour table in IDL? [message #90027 is a reply to message #90022] |
Thu, 15 January 2015 09:28   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Hello David & Jeff,
Thanks for the advice. While I could get the plot as desired, I still find the axis, ticks and labels in 'red' colour (for both the colorbar and plot).
Am I missing something? How can I change the color of axis, ticks and labels to default 'black' color?
------------------------
PRO testplot
tindex = indgen(1000)
d = randomu(1L, 12, 1000)
minval = MIN(d,MAX=maxval)
FigFile = 'testplot1.ps'
cgPS_Open, FigFile
cgDisplay
thick = (!D.Name EQ 'PS') ? 2:1
!P.Multi=0
device, decomposed=0
cgLoadCT, 0
cgLoadCT, 22, /Brewer, ncolors=6
mg_horizon, tindex, d, nbands=6,titles=ytitles, $
xstyle=1, ystyle=1, Xrange=[0,1000], $
Thick=thick, Font=-1, minimum=minval, $
maximum=maxval, Position=[0.1,0.3,0.70,0.94], $
colors=[0, 1, 2, 3, 4, 5]
cgColorbar, ncolors=6, divisions=6, TCharsize=0.12, $
range=[minval,maxval],/right, tlocation='right', $
Title='d',/Vertical, Font=-1, Minor=5, $
Position=[0.81,0.32,0.83,0.90]
; Closing the figure file
cgPS_Close
; Create a PNG file
cgPS2Raster, FigFile, /PNG
END
------------------------------
Thanks in advance,
Regards,
Madhavan
On Thursday, January 15, 2015 at 3:06:42 PM UTC+1, Jeff B wrote:
>> cgLoadCT, 22, /Brewer
>> tvlct, 0, 0, 0, 0
>> tvlct, 255, 255, 255, 255
>>
>> cgColorbar, /Brewer, CTindex=22, TCharsize=0.12, $
>> range=[minval,maxval],/right, tlocation='right', $
>> Title='d',/Vertical, Font=-1, Minor=5, $
>> Position=[0.81,0.32,0.83,0.90]
>
>
> Firstly, you need to add NCOLORS = 6 to both cgLoadCT and cgColorbar, Secondly, don't use the BREWER and CTINDEX keywords when you call cgColorbar; you have already loaded the color table you want. See the difference between
>
> cgLoadCT, 22, /brewer, nColors = 6
> cgColorbar, nColors = 6
>
> and
>
> cgLoadCT, 22, /brewer, nColors = 6
> cgColorbar, /brewer, ctIndex = 22, nColors = 6
>
> The last one does not use the color table you have loaded with cgLoadCT. Also note that when you do
>
> tvlct, 0, 0, 0, 0
>
> you are overwriting the first element of the color table. Therefore, black becomes one of the six colors you are using. If this is not the desired behavior, then perhaps you should place this outside the first six elements. I suggest using cIndex to look at what this does to your color table.
|
|
|
|
|
Re: How to create a colour table in IDL? [message #90031 is a reply to message #90028] |
Fri, 16 January 2015 05:33   |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Thank you David. It works!!!
On Thursday, January 15, 2015 at 6:33:36 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>> Thanks for the advice. While I could get the plot as desired, I still find the axis, ticks and labels in 'red' colour (for both the colorbar and plot).
>>
>> Am I missing something? How can I change the color of axis, ticks and labels to default 'black' color?
>
> Start your color indices at 1 instead of 0. Hint: see the BOTTOM
> keyword. Color index 0 is almost always used as the background color.
> See any color article I've ever written for an example. :-)
>
> 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: How to create a colour table in IDL? [message #90032 is a reply to message #90030] |
Fri, 16 January 2015 05:34  |
atmospheric physics
Messages: 121 Registered: June 2010
|
Senior Member |
|
|
Thank you Nikola.
On Friday, January 16, 2015 at 10:32:56 AM UTC+1, Nikola Vitas wrote:
> Not directly related to the initial question: I have all the Brewer's tables saved as separate .sav files. The variables are named as in the example below. The colors are saved as three (r, g, b) integer arrays. The tarball is at:
> https://db.tt/nEML38BK
>
> Example:
> IDL> restore, 'Oranges_03.sav', /ve
> % RESTORE: Portable (XDR) SAVE/RESTORE file.
> % RESTORE: Restored variable: R.
> % RESTORE: Restored variable: G.
> % RESTORE: Restored variable: B.
> % RESTORE: Restored variable: COLORNAME. ; Oranges
> % RESTORE: Restored variable: NUMOFCOLORS. ; 3
> % RESTORE: Restored variable: COLORNUM. ; 0 1 2
> % RESTORE: Restored variable: TYPE. ; seq
> % RESTORE: Restored variable: SCHEMETYPE. ; Sequential
> % RESTORE: Restored variable: COLORLETTER. ; C
> % RESTORE: Restored variable: CRITVAL. ; 0.0000
|
|
|