how to modify the legend? (fwd)

Rafael Rosolem rosolem at GMAIL.COM
Sat Jun 11 09:13:36 EDT 2005


Dear Charles Seman, Soni Yatheendradas and Gustavo Goncalves,

thank you so very much for the useful scripts. I have modified them a
bit in order to have them working on my own purposes.

regards.

R.



Soni Yatheendradas wrote:

>        Hi Rafael,
>                This might be useful to you perhaps?
>   Soni
>
>
>---------- Forwarded message ----------
>Date: Fri, 10 Jun 2005 16:22:56 -0700
>From: gustavo at hwr.arizona.edu
>To: Soni Yatheendradas <soni at hwr.arizona.edu>
>Subject: Re: how to modify the legend? (fwd)
>
>Hello Soni,
>pass to your friend Rafael Rosolem, the script below. What matters is the
>function colorbar(args) so attention to the way the argument is passed to "%"
>symbol for this particular case. Mr. Rosolem could either include the modified
>function colorbar in his scripts or create his own UDF (User Defined Function).
>Ask him to contact me if more assistence is required.
>I think Mike Fiorino already figured something out but I am too lazy to use
>google today.
>Hope it helps.
>
>Cheers
>
>Gustavo
>
>* just took the cbar.gs and changed the code in order to add symbols
>* at the end of the colorbar numbers (if this is what you are looking for)
>* probably Mike Fiorino already did something similar.
>* Use as function in your scripts
>* or create your own grads user defined function (UDF)
>
>'reinit'
>'open flx.ft06.200504.ctl'
>
>* I had nothing better (and quick) to think about as an example for
>* you at this time so just calculated the percent departure
>* of the surface temperature on april 1st 2005 00Z
>* from the average temperature for april/2005 reanalysis
>* over South America. Just numbers...
>
>'define avetmp=ave(tmpsfc,t=1,t=120)'
>'define tmp=100*(tmpsfc(t=1)/avetmp)'
>'set gxout shaded'
>'d tmp'
>
>* here you chose what symbol you want to come after your values
>arg="%"
>
>* plot colobar
>colorbar(arg)
>
>function colorbar (args)
>*
>*  Check shading information
>*
>  'query shades'
>  shdinfo = result
>  if (subwrd(shdinfo,1)='None')
>    say 'Cannot plot color bar: No shading information'
>    return
>  endif
>*
>*  Get plot size info
>*
>  'query gxinfo'
>  rec2 = sublin(result,2)
>  rec3 = sublin(result,3)
>  rec4 = sublin(result,4)
>  xsiz = subwrd(rec2,4)
>  ysiz = subwrd(rec2,6)
>  ylo = subwrd(rec4,4)
>  xhi = subwrd(rec3,6)
>  xd = xsiz - xhi
>*
>*  Decide if horizontal or vertical color bar
>*  and set up constants.
>*
>  if (ylo<0.6 & xd<1.0)
>    say "Not enough room in plot for a colorbar"
>    return
>  endif
>  cnum = subwrd(shdinfo,5)
>  if (ylo<0.6 | xd>1.5)
>    xl = xhi + xd/2 - 0.4
>    xr = xl + 0.2
>    xwid = 0.2
>    ywid = 0.5
>    if (ywid*cnum > ysiz*0.8)
>      ywid = ysiz*0.8/cnum
>    endif
>    ymid = ysiz/2
>    yb = ymid - ywid*cnum/2
>    'set string 1 l 5'
>    vert = 1
>  else
>    ymid = ylo/2
>    yt = ymid + 0.2
>    yb = ymid
>    xmid = xsiz/2
>    xwid = 0.8
>    if (xwid*cnum > xsiz*0.8)
>      xwid = xsiz*0.8/cnum
>    endif
>    xl = xmid - xwid*cnum/2
>    'set string 1 tc 5'
>    vert = 0
>  endif
>*
>*  Plot colorbar
>*
>  'set strsiz 0.12 0.13'
>  num = 0
>  while (num<cnum)
>    rec = sublin(shdinfo,num+2)
>    col = subwrd(rec,1)
>    hi = subwrd(rec,3)
>    'set line 'col
>    if (vert)
>      yt = yb + ywid
>    else
>      xr = xl + xwid
>    endif
>    'draw recf 'xl' 'yb' 'xr' 'yt
>    if (num<cnum-1)
>      if (vert)
>        'draw string '%(xr+0.05)%' '%(yt-0.2)%' 'hi' 'args
>      else
>        'draw string 'xr' '%(yb-0.05)%' 'hi' 'args
>      endif
>    endif
>    num = num + 1
>    if (vert); yb = yt;
>    else; xl = xr; endif;
>  endwhile
>
>
>
>
>
>
>
>
>Quoting Soni Yatheendradas <soni at hwr.arizona.edu>:
>
>
>
>>---------- Forwarded message ----------
>>Date: Fri, 10 Jun 2005 09:26:30 -0300
>>From: Rafael Rosolem <rosolem at GMAIL.COM>
>>Reply-To: GRADSUSR at list.cineca.it
>>To: GRADSUSR at list.cineca.it
>>Subject: how to modify the legend?
>>
>>Dear all,
>>
>>I have a simple question:
>>
>>I have a t-test plot of the precipitation where I define 4 different
>>levels of significance which are 75% (1.1517), 90% (1.6480), 95%
>>(1.9649), and 99% (2.6862). now I would like to replace the labels from
>>numbers to percentage. is there anyway I could do it? does someone have
>>a script which does that?
>>
>>many thanks.
>>
>>R.
>>
>>ps: please find attached the figure.
>>
>>
>>
>
>
>
>
>-------------------------------------------------
>
>
>



More information about the gradsusr mailing list