Re: Add a colorbar in a filled contour [message #60922] |
Wed, 25 June 2008 05:54  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Jun 25, 5:01 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
> Dear all,
>
> I am using D Fanning's colorbar routine.
> But I have some questions about the corresponding value for each
> color.
>
> For example,
>
> A=DIS(31,41)
> DEVICE, DECOMPOSED=0
> LOADCT, 5, NCOLORS=100
> CONTOUR, A, POSITION=[0.15, 0.15, 0.95, 0.75], $
> C_COLORS=INDGEN(100), NLEVELS=100, /FILLl
>
> For min(A)=0 and max(A)=25, the color with index '0' should present
> the value '0' and the color with index '99' should present the value
> '25'.
> Therefore, when I use the COLORBAR routine, the keywords RANGE should
> be given.
> COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90],
> RANGE=[min(A), max(A)]
> Is it right?
>
> If the minimum or maximum of the array has a floating-point value like
> 3.24, is the above command to add the colorbas still right?
>
Hi,
I think you'll be OK, although you should see David's article on
specifying the contour levels manually (http://dfanning.com/tips/
nlevels.html). Also, you will want to control the tick value format
as Colorbar's default is to label the tick values as integers.
I realize that you have posted a simple example, but I wonder about
the purpose of a filled contour image with 100 levels. As a display
technique will that be much different from simply using David's
TVSCALE (or Liam Gumley's IMDISP) to show the array scaled into the
color indices 0-100?
Anyway, here is your example modified to scale the data 0-3.24 with a
colorbar.
Cheers,
Ben
A=DIST(31,41)
minA = MIN(A, MAX = maxA)
A = (A-minA)/(maxA-MinA) * 3.24 ;rescale to the range 0.0 - 3.24
DEVICE, DECOMPOSED=0
LOADCT, 5, NCOLORS=100
CONTOUR, A, POSITION=[0.15, 0.15, 0.95, 0.75],$
C_COLORS = INDGEN(100), NLEVELS = 100, /FILL
COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90], $
RANGE=[min(A), max(A)], FORMAT = '(F0.2)'
|
|
|
Re: Add a colorbar in a filled contour [message #61034 is a reply to message #60922] |
Thu, 26 June 2008 20:44  |
duxiyu@gmail.com
Messages: 88 Registered: March 2007
|
Member |
|
|
Thanks for your reply.
It is very helpful.
Cheers,
Du Jian
On Jun 25, 8:54 pm, "ben.bighair" <ben.bigh...@gmail.com> wrote:
> On Jun 25, 5:01 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>
>
>> Dear all,
>
>> I am using D Fanning'scolorbarroutine.
>> But I have some questions about the corresponding value for each
>> color.
>
>> For example,
>
>> A=DIS(31,41)
>> DEVICE, DECOMPOSED=0
>> LOADCT, 5, NCOLORS=100
>> CONTOUR, A, POSITION=[0.15, 0.15, 0.95, 0.75], $
>> C_COLORS=INDGEN(100), NLEVELS=100, /FILLl
>
>> For min(A)=0 and max(A)=25, the color with index '0' should present
>> the value '0' and the color with index '99' should present the value
>> '25'.
>> Therefore, when I use theCOLORBARroutine, the keywords RANGE should
>> be given.
>> COLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90],
>> RANGE=[min(A), max(A)]
>> Is it right?
>
>> If the minimum or maximum of the array has a floating-point value like
>> 3.24, is the above command to add the colorbas still right?
>
> Hi,
>
> I think you'll be OK, although you should see David's article on
> specifying the contour levels manually (http://dfanning.com/tips/
> nlevels.html). Also, you will want to control the tick value format
> asColorbar'sdefault is to label the tick values as integers.
>
> I realize that you have posted a simple example, but I wonder about
> the purpose of a filled contour image with 100 levels. As a display
> technique will that be much different from simply using David's
> TVSCALE (or Liam Gumley's IMDISP) to show the array scaled into the
> color indices 0-100?
>
> Anyway, here is your example modified to scale the data 0-3.24 with acolorbar.
>
> Cheers,
> Ben
>
> A=DIST(31,41)
> minA = MIN(A, MAX = maxA)
> A = (A-minA)/(maxA-MinA) * 3.24 ;rescale to the range 0.0 - 3.24
> DEVICE, DECOMPOSED=0
> LOADCT, 5, NCOLORS=100
> CONTOUR, A, POSITION=[0.15, 0.15, 0.95, 0.75],$
> C_COLORS = INDGEN(100), NLEVELS = 100, /FILLCOLORBAR, NCOLORS=100, POSITION=[0.15, 0.85, 0.95, 0.90], $
> RANGE=[min(A), max(A)], FORMAT = '(F0.2)'
|
|
|