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

Home » Public Forums » archive » Re: Issues with cgColorbar labels
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
Re: Issues with cgColorbar labels [message #77792] Fri, 23 September 2011 03:26
John Ilee 2 is currently offline  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 Go to previous message
Bob[4] is currently offline  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 #77799 is a reply to message #77796] Thu, 22 September 2011 09:35 Go to previous message
Brian Wolven is currently offline  Brian Wolven
Messages: 94
Registered: May 2011
Member
Surely it would be easier just to multiply the data by 100? =P
Re: Issues with cgColorbar labels [message #77800 is a reply to message #77799] Thu, 22 September 2011 09:17 Go to previous message
David Fanning is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: ERROR_MESSAGE
Next Topic: YAIB (yet another IDL blog)

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

Current Time: Wed Oct 08 13:34:00 PDT 2025

Total time taken to generate the page: 0.00690 seconds