Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
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?
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
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
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
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
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.")
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.")
Hello, I want to make 6 colour bands (and 7 labels) with Brewer colour table similar to the colorbar shown at http://latticeextra.r-forge.r-project.org/#horizonplot ? Can anyone help me how I shall use cgLoadCT and cgColorbar to obtain the 6 colour bands from Brewer colour table? Thanks in advance, Madhavan
Madhavan Bomidi writes: > I want to make 6 colour bands (and 7 labels) with Brewer colour table similar to the colorbar shown at http://latticeextra.r-forge.r-project.org/#horizonplot ? > > Can anyone help me how I shall use cgLoadCT and cgColorbar to obtain the 6 colour bands from Brewer colour table? The answer to this question is pretty simple. Just use them in the normal way. Are you maybe looking for the on-line help? http://www.idlcoyote.com/idldoc/cg/cgloadct.html http://www.idlcoyote.com/idldoc/cg/cgcolorbar.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.")
Hello David, 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? Thanks and regards, Madhavan On Wednesday, January 14, 2015 at 4:59:29 PM UTC+1, David Fanning wrote: > Madhavan Bomidi writes: > >> I want to make 6 colour bands (and 7 labels) with Brewer colour table similar to the colorbar shown at http://latticeextra.r-forge.r-project.org/#horizonplot ? >> >> Can anyone help me how I shall use cgLoadCT and cgColorbar to obtain the 6 colour bands from Brewer colour table? > > The answer to this question is pretty simple. Just use them in the > normal way. Are you maybe looking for the on-line help? > > http://www.idlcoyote.com/idldoc/cg/cgloadct.html > http://www.idlcoyote.com/idldoc/cg/cgcolorbar.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.")
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.")
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.")
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.")
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 --------------------------------------
Madhavan Bomidi writes: > 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? I suggest if you want just six colors, you use the NCOLORS=6 keyword on cgLoadCT and cgColorbar. Sigh... 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.")
> 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.
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.
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.")
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
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.")