Re: Issues with cgColorbar labels [message #77792] |
Fri, 23 September 2011 03:26 |
John Ilee 2
Messages: 2 Registered: September 2011
|
Junior Member |
|
|
On Sep 22, 5:17 pm, David Fanning <sageande...@gmail.com> wrote:
> On Sep 22, 8:02 am, John Ilee 2 <johnism...@googlemail.com> wrote:
>
>
>
>
>
>
>
>
>
>> I have been trying to find a simple way of producing a filled contour
>> plot with a colour bar in IDL for some time. However, I always seem
>> to run into issues when it comes to the labels on the colour bar.
>
>> I have tried the following example from David Fanning's excellent
>> website...
>
>> data = cgDemoData(2)
>> LoadCT, 0
>> LoadCT, 33, NColors=10, Bottom=1
>> c_colors = Indgen(10)+1
>> position = [0.1, 0.1, 0.9, 0.75]
>> cgContour, data, NLevels=10, /Fill, Position=position,
>> C_Colors=c_colors
>> cgColorbar, Divisions=10, Range=[Min(data), Max(data)], XMinor=1, $
>> XTickLen=1.0, Position=[0.1, 0.90, 0.9, 0.94], NColors=10,
>> BOTTOM=1
>
>> ...which works perfectly.
>
>> However, when I try to use the above commands with my own dataset (eg
>> 'data = myarray', which is a 1024x512 array, min value 0.51, max value
>> 1.27), the colour bar labels just display "1" at every tickmark.
>
>> If anyone can point me in the direction of a solution, it would be
>> most appreciated. I know it must be something simple, but I just
>> can't seem to figure it out.
>
>> (I am running IDL 7.1)
>
>> Many thanks.
>
> Try the FORMAT keyword on the cgColorbar. Something like
> FORMAT='(F0.2)'
> should work.
>
> Cheers,
>
> David
That fixed it.
Thanks for all the suggestions.
|
|
|
Re: Issues with cgColorbar labels [message #77796 is a reply to message #77792] |
Thu, 22 September 2011 14:12  |
Bob[4]
Messages: 24 Registered: April 2009
|
Junior Member |
|
|
Try applying this diff to cgcolorbar.pro, then it will probably work the way you expect.
diff a/cgcolorbar.pro b/cgcolorbar.pro
84c84
< ; be (divisions + 1) annotations. The default is 6.
---
> ; be (divisions + 1) annotations. The default is chosen internally.
94c94
< ; FORMAT: The format of the bar annotations. Default is '(I0)'.
---
> ; FORMAT: The format of the bar annotations. Default is ''.
368c368
< IF N_ELEMENTS(format) EQ 0 THEN format = '(I0)'
---
> IF N_ELEMENTS(format) EQ 0 THEN format = ''
378c378
< IF N_ELEMENTS(divisions) EQ 0 THEN divisions = 6
---
> IF N_ELEMENTS(divisions) EQ 0 THEN divisions = 0
|
|
|
|
Re: Issues with cgColorbar labels [message #77800 is a reply to message #77799] |
Thu, 22 September 2011 09:17  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
On Sep 22, 8:02 am, John Ilee 2 <johnism...@googlemail.com> wrote:
> I have been trying to find a simple way of producing a filled contour
> plot with a colour bar in IDL for some time. However, I always seem
> to run into issues when it comes to the labels on the colour bar.
>
> I have tried the following example from David Fanning's excellent
> website...
>
> data = cgDemoData(2)
> LoadCT, 0
> LoadCT, 33, NColors=10, Bottom=1
> c_colors = Indgen(10)+1
> position = [0.1, 0.1, 0.9, 0.75]
> cgContour, data, NLevels=10, /Fill, Position=position,
> C_Colors=c_colors
> cgColorbar, Divisions=10, Range=[Min(data), Max(data)], XMinor=1, $
> XTickLen=1.0, Position=[0.1, 0.90, 0.9, 0.94], NColors=10,
> BOTTOM=1
>
> ...which works perfectly.
>
> However, when I try to use the above commands with my own dataset (eg
> 'data = myarray', which is a 1024x512 array, min value 0.51, max value
> 1.27), the colour bar labels just display "1" at every tickmark.
>
> If anyone can point me in the direction of a solution, it would be
> most appreciated. I know it must be something simple, but I just
> can't seem to figure it out.
>
> (I am running IDL 7.1)
>
> Many thanks.
Try the FORMAT keyword on the cgColorbar. Something like
FORMAT='(F0.2)'
should work.
Cheers,
David
|
|
|