cgScaleVector and diverging colorbar help [message #91284] |
Thu, 25 June 2015 08:59  |
sam.tushaus
Messages: 14 Registered: February 2015
|
Junior Member |
|
|
Hello all! I'm trying to create a plot with a diverging colorbar. I would like white to correspond to 0, and my data is typically in the range [-5,70] on a latitude-longitude grid.
I've been using this page (http://www.idlcoyote.com/code_tips/scaleimage.html) as a reference. The first problem comes when I try to use cgImage to display my scaled data - the map becomes highly distorted. Is there any way to fix this?
My second problem comes when I try to use cgContour to display my scaled data instead of cgImage. The contouring looks generally correct, but the whole range of the colorbar is used in the contouring. This is a problem because my data range is [-5,70] and I want 0 to be white.
I really appreciate any comments or hints on how to fix this. Thanks!
|
|
|
Re: cgScaleVector and diverging colorbar help [message #91285 is a reply to message #91284] |
Thu, 25 June 2015 09:16   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
sam.tushaus@gmail.com writes:
> Hello all! I'm trying to create a plot with a diverging colorbar. I would like white to correspond to 0, and my data is typically in the range [-5,70] on a latitude-longitude grid.
>
> I've been using this page (http://www.idlcoyote.com/code_tips/scaleimage.html) as a reference. The first problem comes when I try to use cgImage to display my scaled data - the map becomes highly distorted. Is there any way to fix this?
>
> My second problem comes when I try to use cgContour to display my scaled data instead of cgImage. The contouring looks generally correct, but the whole range of the colorbar is used in the contouring. This is a problem because my data range is [-5,70] and I want 0 to be white.
>
> I really appreciate any comments or hints on how to fix this
data = cgScaleVector(cgDemoData(7), -5, 70)
Loadct, 0 ; Reset colors
cgLoadct, 1, NColors=10, Clip=[100,250]
cgLoadCt, 3, NColors=140, Bottom=11, /Reverse
TVLCT, cgColor('white', /Triple), 10
cgImage, BytScl(data, Top=151), Position=[0.125, 0.1, 0.925, 0.75]
cgColorbar, NColors=151
cIndex
END
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: cgScaleVector and diverging colorbar help [message #91286 is a reply to message #91285] |
Thu, 25 June 2015 09:19   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>
> sam.tushaus@gmail.com writes:
>
>> Hello all! I'm trying to create a plot with a diverging colorbar. I would like white to correspond to 0, and my data is typically in the range [-5,70] on a latitude-longitude grid.
>>
>> I've been using this page (http://www.idlcoyote.com/code_tips/scaleimage.html) as a reference. The first problem comes when I try to use cgImage to display my scaled data - the map becomes highly distorted. Is there any way to fix this?
>>
>> My second problem comes when I try to use cgContour to display my scaled data instead of cgImage. The contouring looks generally correct, but the whole range of the colorbar is used in the contouring. This is a problem because my data range is [-5,70] and I want 0 to be white.
>>
>> I really appreciate any comments or hints on how to fix this
>
> data = cgScaleVector(cgDemoData(7), -5, 70)
> Loadct, 0 ; Reset colors
> cgLoadct, 1, NColors=10, Clip=[100,250]
> cgLoadCt, 3, NColors=140, Bottom=11, /Reverse
> TVLCT, cgColor('white', /Triple), 10
> cgImage, BytScl(data, Top=151), Position=[0.125, 0.1, 0.925, 0.75]
> cgColorbar, NColors=151
> cIndex
> END
Whoops! The cgColorbar command should have a range on it:
cgColorbar, NColors=151, Range=[-5, 70]
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: cgScaleVector and diverging colorbar help [message #91287 is a reply to message #91286] |
Thu, 25 June 2015 09:23   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Whoops! The cgColorbar command should have a range on it:
>
> cgColorbar, NColors=151, Range=[-5, 70]
Sigh... Going back to bed. Let's try this again:
data = cgScaleVector(cgDemoData(7), -5, 70)
Loadct, 0 ; Reset colors
cgLoadct, 1, NColors=10, Clip=[100,250]
cgLoadCt, 3, NColors=140, Bottom=11, /Reverse
TVLCT, cgColor('white', /Triple), 10
cgImage, BytScl(data, Top=150), Position=[0.125, 0.1, 0.925, 0.75]
cgColorbar, NColors=151, Range=[-5, 70]
cIndex
END
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: cgScaleVector and diverging colorbar help [message #91288 is a reply to message #91287] |
Thu, 25 June 2015 09:31   |
sam.tushaus
Messages: 14 Registered: February 2015
|
Junior Member |
|
|
Thanks! The scaling looks great. However, my image is still distorted (http://imgur.com/zj4DKnt, should be Great Lakes region).
Also, do you think I might be able to automate the color table creation, using the range/min/max?
On Thursday, June 25, 2015 at 11:23:40 AM UTC-5, David Fanning wrote:
> David Fanning writes:
>
>> Whoops! The cgColorbar command should have a range on it:
>>
>> cgColorbar, NColors=151, Range=[-5, 70]
>
> Sigh... Going back to bed. Let's try this again:
>
> data = cgScaleVector(cgDemoData(7), -5, 70)
> Loadct, 0 ; Reset colors
> cgLoadct, 1, NColors=10, Clip=[100,250]
> cgLoadCt, 3, NColors=140, Bottom=11, /Reverse
> TVLCT, cgColor('white', /Triple), 10
> cgImage, BytScl(data, Top=150), Position=[0.125, 0.1, 0.925, 0.75]
> cgColorbar, NColors=151, Range=[-5, 70]
> cIndex
> END
>
> 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: cgScaleVector and diverging colorbar help [message #91291 is a reply to message #91290] |
Thu, 25 June 2015 10:10   |
sam.tushaus
Messages: 14 Registered: February 2015
|
Junior Member |
|
|
On Thursday, June 25, 2015 at 11:44:43 AM UTC-5, David Fanning wrote:
> sam.tushaus@gmail.com writes:
>
>> Thanks! The scaling looks great. However, my image is still distorted (http://imgur.com/zj4DKnt, should be Great Lakes region).
>
> Set the /KEEP_ASPECT keyword on your cgImage call.
>
>> Also, do you think I might be able to automate the color table creation, using the range/min/max?
>
> Certainly, IDL is a programming language!
>
> 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.")
Haha of course! I'll figure something out :)
Do you have any tips on how to use cgContour to plot my data instead of cgImage?
|
|
|
|
Re: cgScaleVector and diverging colorbar help [message #91300 is a reply to message #91294] |
Fri, 26 June 2015 11:25  |
sam.tushaus
Messages: 14 Registered: February 2015
|
Junior Member |
|
|
On Thursday, June 25, 2015 at 1:52:36 PM UTC-5, David Fanning wrote:
> sam.tushaus@gmail.com writes:
>
>> Do you have any tips on how to use cgContour to plot my data instead of cgImage?
>
> Yes, have you ever had a look at my web page? Tips galore! In
> particular, these pages:
>
> http://www.idlcoyote.com/graphics_tips/graphics_tips.php
> http://www.idlcoyote.com/gallery/index.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.")
I was having some problems with cgContour yesterday, but everything seems to be great today! I guess the computer and I just needed a break. Thanks for all your help!
|
|
|