Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
colorbar to display the 0 in the middle
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vige...@gmail.com  
View profile  
 More options Feb 9 2006, 8:53 pm
Newsgroups: comp.lang.idl-pvwave
From: vige...@gmail.com
Date: 9 Feb 2006 17:53:11 -0800
Local: Thurs, Feb 9 2006 8:53 pm
Subject: colorbar to display the 0 in the middle
Hi,

I'm working on a simulation stuff, computationally speaking, its
nothing but generating images for each instant of time.:-)
Each image is accompanied by a colorbar( I use D.Fanning's colorbar
program).

Now my problem is......
At each instant of time, the array that has to be displayed has a
negative minimum value and a positive maximum value. I want my colorbar
to display the 0 in the middle of the bar for all the time instant and
scale the rest according to the min and max value.
There could be a simple solution for this, please help.

Thank you,
Vigeesh.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fanning  
View profile  
 More options Feb 9 2006, 11:01 pm
Newsgroups: comp.lang.idl-pvwave
From: David Fanning <dav...@dfanning.com>
Date: Thu, 9 Feb 2006 21:01:59 -0700
Local: Thurs, Feb 9 2006 11:01 pm
Subject: Re: colorbar to display the 0 in the middle

vige...@gmail.com writes:
> I'm working on a simulation stuff, computationally speaking, its
> nothing but generating images for each instant of time.:-)
> Each image is accompanied by a colorbar( I use D.Fanning's colorbar
> program).

> Now my problem is......
> At each instant of time, the array that has to be displayed has a
> negative minimum value and a positive maximum value. I want my colorbar
> to display the 0 in the middle of the bar for all the time instant and
> scale the rest according to the min and max value.
> There could be a simple solution for this, please help.

How about this:

   minVal = -30
   maxVal = 30
   Colorbar, Range=[minVal, maxVal]

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vigeesh Nambiar  
View profile  
 More options Feb 10 2006, 12:51 am
Newsgroups: comp.lang.idl-pvwave
From: "Vigeesh Nambiar" <vige...@gmail.com>
Date: 9 Feb 2006 21:51:01 -0800
Local: Fri, Feb 10 2006 12:51 am
Subject: Re: colorbar to display the 0 in the middle

David Fanning wrote:
> How about this:

>    minVal = -30
>    maxVal = 30
>    Colorbar, Range=[minVal, maxVal]

But, I want something like this
minval = -30
maxval = +50

i.e my colorbar should look something like this
______  50
|    |
|    |
|    |
|    |
|    |
|    |
|    |-  0
|    |
|    |
|    |
|    |
|    |
|    |
------- -30

:-)

Basically, what I want is that the color for the data value 0 should be
the same for all the output images. That is, if I use a Blue-Red color
table, then the 0 data value should always be green. The main problem
is because the minimum and maximum value keeps on changing for
different arrays. If for the first array the min value is -30 and max
is 50, for the second array it might be -50 and +75, and so on.

Thanks,

Vigeesh.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fanning  
View profile  
 More options Feb 10 2006, 6:12 am
Newsgroups: comp.lang.idl-pvwave
From: David Fanning <dav...@dfanning.com>
Date: Fri, 10 Feb 2006 04:12:03 -0700
Local: Fri, Feb 10 2006 6:12 am
Subject: Re: colorbar to display the 0 in the middle

Are you SURE that is what you want? Differential scaling on the positive
and negative sides of your data, and differential scaling on all data
sets!? Wouldn't you want to *compare* the data at some point?

I don't know. It's your data analysis. But this is simply a mapping
problem. Scale negative values into 100 values. Scale positive values
into 100 values. Use a color table that has 200 values. Label it with
YTICKV (since the scale is no longer linear). Just don't include my
name in the acknowledgements, please. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ph le sager  
View profile  
 More options Feb 10 2006, 6:48 am
Newsgroups: comp.lang.idl-pvwave
From: "ph le sager" <plesa...@meteo.noa.gr>
Date: 10 Feb 2006 03:48:28 -0800
Local: Fri, Feb 10 2006 6:48 am
Subject: Re: colorbar to display the 0 in the middle
Do you want ALL values or only 0 to be always represented by the same
color?

If you want all, you will need to go with David's answer and always use
the same range in the bar, whatever the data range.

If you want only the 0-level with the same color, you have to be sure
that, for each of your filled contour plot, you have the same color
loaded for the level 0. That means you need to have a contour level
equal to 0, and always assign the same color from the same table to
this 0-level.
Here is a little program that provides a solution. The color in the
middle of the original colortable is assigned to the 0-level, if you
have a 0-level (you need to correctly define RANGE and NFILL -and
that's it-), set the keyword /CENTERED, and use SHIFT to pass to
colorbar. Try the examples, you may change ct to a valid colortable #
(IDL does not come with nice diverging color scheme).

;+
;  This program is to get the contour LEVELS and their COLOR INDICES,
;  according to the NUMBER of filled contours, and the RANGE to
;  consider. The two lattest are the inputs:
;
;
;  INPUTS
;     nfill: number of contour-colors.
;
;     range: this fltarr(2) gives the limits of the
;            colorbar. Range[0] is the first contour level.
Range[1]-step
;            is the last contour.
;
;  INPUT KEYWORD
;     center: to center the color table on level=0. This is very
;             useful for diverging data. If nfill and range are such
;             that there is no levels=0 , then the
;             center of the table is aligned with the first value
;             above 0.
;
;
;  OUTPUT KEYWORDS
;     ccolors: set to variable that will hold contour color indices
;      levels: set to variable that will hold contour levels
;       shift: set to variable that will hold index shift for colorbar
;
;
;
; EFFECT
;  A limited number of colors is loaded from the color table, starting
;  at index 4 by default (this can be changed with keyword BOTTOM,
;  which is passed to LoadCT). You can load any other color in indices
;  0 to 3. Indice 255 (default plotting) may be untouched and free for
;  modification, but only if you do not ask for too much color!!
;
;  It is possible to center the color table on contour-level=0. This
;  is convenient for diverging data (see examples).
;  In this case, a SHIFT value is computed for input to COLORBAR
;  (from David Fanning) to ensure that
;  contour levels and the colorbar match each other.
;
;
; LIMITATION
;  Typical usage is shown in examples below. The idea is to choose the
;  range and nfill such that we can have integer contours. For example,
;  nfill=4 and range=[0,4]. The number of color, nfill, can be
increased,
;  but "should" be a multiple of (range[1]-range[0]). See example #3.
;
;  The limit on colors number (nfill) is 252 by default [ 256-bottom
;  in general case], but it can be less if keyword CENTERED is set,
;  because additional colors that are not needed for contours are set.
; A warning message is displayed in case the limit is exceeded.
;
;
; EXAMPLES:
;   Add POSITION, and compare the following with a set of data between
[-2.,4.]:
;  [ Note that divisions (colorbar keyword, default=6) should be set to
;  a small divisor of nfill for lisibility. Here default works ]
;
;
;  EXAMPLE (1):
;     nfill=6 & range=[-2.,4.]   ; inputs
;
;     contour_definition, nfill, range , 41, ccolors=cc, levels=lev
;     contour, data, c_colors=cc, levels=lev
;     colorbar, ncolors=nfill, range=range, bottom=4 ; (default bottom
;                                                           here)
;
;
;  EXAMPLE (2):
;     nfill=6 & range=[-2.,4.]   ; inputs
;
;     contour_definition, nfill, range, /centered, 41, ccolors=cc, $
;                         levels=lev, shift=shift
;     contour, data, c_colors=cc, levels=lev
;     colorbar, ncolors=nfill, range=range, bottom=4+shift
;
;
;  EXAMPLE (3):
;     nfill=120 & range=[-2.,4.]   ; inputs
;
;     contour_definition, nfill, range, /centered, 41, ccolors=cc, $
;                         levels=lev, shift=shift
;     contour, data, c_colors=cc, levels=lev
;     colorbar, ncolors=nfill, range=range, bottom=4+shift, divisions=3
;
;
;  Written by Philippe Le Sager, NOA, 2004
;
;-

pro contour_definition, nfill, range, ct, centered=centered,
bottom=bot, $
  ccolors=ccolors, levels=levels, shift=shift

on_error, 2

   ncolor=nfill
   shift=0
   if n_elements(bot) eq 0 then bot=4

   ; levels
   step = (range[1] - range[0]) / nfill
   levels = indgen(nfill) * step + range[0]

   ; case of centered ct for diverging data
   if keyword_set(centered) then begin

      n_above = total( levels ge 0., /integer)
      n_below = total( levels lt 0., /integer)

      ncolor = ( n_above > n_below )*2

      if n_above gt n_below then shift = (ncolor-nfill)

   endif

   ; check ncolor
   if fix(ncolor) gt (256-bot) then $
     ok = dialog_message(['TOO MUCH COLORS for Contour...', 'Results
are NOT reliable'])

   ; load ct
   LoadCT, ct, NColors=ncolor, Bottom=bot, /SILENT

   ccolors = Indgen(nfill)+bot+shift

END


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vigeesh Nambiar  
View profile  
 More options Feb 10 2006, 10:22 am
Newsgroups: comp.lang.idl-pvwave
From: "Vigeesh Nambiar" <vige...@gmail.com>
Date: 10 Feb 2006 07:22:23 -0800
Local: Fri, Feb 10 2006 10:22 am
Subject: Re: colorbar to display the 0 in the middle

> Are you SURE that is what you want? Differential scaling on the positive
> and negative sides of your data, and differential scaling on all data
> sets!?

Yes, this is exactly what I want

>Wouldn't you want to *compare* the data at some point?

I'm not interested in the whole data.
Just want to see the pattern of 0's in the image, and also to know what
are the maximum and minimum values at each instant and to look at the
gradient on both side(positive and negative, seperately), eventhough
they are not the same.

Anyway, thank you very much

>Just don't include my name in the acknowledgements, please. :-)

Are you sure? :-)

Thank you again.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vigeesh Nambiar  
View profile  
 More options Feb 10 2006, 10:25 am
Newsgroups: comp.lang.idl-pvwave
From: "Vigeesh Nambiar" <vige...@gmail.com>
Date: 10 Feb 2006 07:25:39 -0800
Local: Fri, Feb 10 2006 10:25 am
Subject: Re: colorbar to display the 0 in the middle

>Do you want ALL values or only 0 to be always represented by the same
>color?

As I mentioned I want only 0 to be represented by the same color.

Thank you for the program. I'll try it and let you know if it works.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fanning  
View profile  
 More options Feb 10 2006, 10:59 am
Newsgroups: comp.lang.idl-pvwave
From: David Fanning <dav...@dfanning.com>
Date: Fri, 10 Feb 2006 08:59:30 -0700
Local: Fri, Feb 10 2006 10:59 am
Subject: Re: colorbar to display the 0 in the middle

Vigeesh Nambiar writes:
> As I mentioned I want only 0 to be represented by the same color.

> Thank you for the program. I'll try it and let you know if it works.

After fooling around with this for a few minutes, I
suspect you may have to write your own colorbar routine.
Mine uses PLOT to draw annotations, and I don't think you
can get PLOT to do useful things in non-linear space. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sav...@nsidc.org  
View profile  
 More options Feb 10 2006, 11:11 am
Newsgroups: comp.lang.idl-pvwave
From: sav...@nsidc.org
Date: Fri, 10 Feb 2006 09:11:10 -0700
Local: Fri, Feb 10 2006 11:11 am
Subject: Re: colorbar to display the 0 in the middle

David Fanning <dav...@dfanning.com> writes:
> Vigeesh Nambiar writes:

>> As I mentioned I want only 0 to be represented by the same color.

>> Thank you for the program. I'll try it and let you know if it works.

> After fooling around with this for a few minutes, I
> suspect you may have to write your own colorbar routine.
> Mine uses PLOT to draw annotations, and I don't think you
> can get PLOT to do useful things in non-linear space. :-)

Wow, you *really* don't want to be attatched to that do you? :)

--
Matthew Savoie  -  Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785   http://nsidc.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vigeesh Nambiar  
View profile  
 More options Feb 12 2006, 1:54 am
Newsgroups: comp.lang.idl-pvwave
From: "Vigeesh Nambiar" <vige...@gmail.com>
Date: 11 Feb 2006 22:54:31 -0800
Local: Sun, Feb 12 2006 1:54 am
Subject: Re: colorbar to display the 0 in the middle

David Fanning wrote:
> After fooling around with this for a few minutes, I
> suspect you may have to write your own colorbar routine.
> Mine uses PLOT to draw annotations, and I don't think you
> can get PLOT to do useful things in non-linear space. :-)

Do you think that I can write a colorbar routine that uses two
different data sets on the same colorbar, one of which is plotted above
0 and the other below zero with this very little knowledge of IDL
programming and data analysis.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fanning  
View profile  
 More options Feb 12 2006, 10:57 am
Newsgroups: comp.lang.idl-pvwave
From: David Fanning <dav...@dfanning.com>
Date: Sun, 12 Feb 2006 08:57:05 -0700
Local: Sun, Feb 12 2006 10:57 am
Subject: Re: colorbar to display the 0 in the middle

Vigeesh Nambiar writes:
> Do you think that I can write a colorbar routine that uses two
> different data sets on the same colorbar, one of which is plotted above
> 0 and the other below zero with this very little knowledge of IDL
> programming and data analysis.

I don't think it is a lack of IDL knowledge that is holding you
back right now.

Creating the color bar is trivial. It is scaling the
data properly that is the difficult part. And although
you have convinced me this is what YOU want, I'm just not
sure the rest of the scientific community is ready for
this kind of innovation. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
larsonej  
View profile  
 More options Sep 30 2012, 7:22 pm
Newsgroups: comp.lang.idl-pvwave
From: larsonej <larso...@colorado.edu>
Date: Sun, 30 Sep 2012 18:22:50 -0500
Local: Sun, Sep 30 2012 7:22 pm
Subject: RE: colorbar to display the 0 in the middle
I have a very simple question that I am having trouble finding an answer to. It is related to this post however. I have a contour map with defined contours in log scale. that go from -4 to 4. I want to make a colorbar to go with it. However, putting the min range = -4 and the max range = 4 and setting /log or /ylog gives me a colorbar that stays positive. Any thoughts? Is there an easy way to do this, or do I have to create a positive and negative colorbar next to each other?
Erik

--http://compgroups.net/comp.lang.idl-pvwave/colorbar-to-display-the-0-...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fanning  
View profile  
 More options Sep 30 2012, 7:47 pm
Newsgroups: comp.lang.idl-pvwave
From: David Fanning <n...@idlcoyote.com>
Date: Sun, 30 Sep 2012 17:47:28 -0600
Local: Sun, Sep 30 2012 7:47 pm
Subject: RE: colorbar to display the 0 in the middle

larsonej writes:
> I have a very simple question that I am having trouble finding an answer to. It is related to this post however. I have a contour map with defined contours in log scale. that go from -4 to 4. I want to make a colorbar to go with it. However, putting the min range = -4 and the max range = 4 and setting /log or /ylog gives me a colorbar that stays positive. Any thoughts? Is there an easy way to do this, or do I have to create a positive and negative colorbar next to each
other?

I suppose you could do this:

IDL> cgcolorbar, range=[1./1e4,1e4], /xlog

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »