[gradsusr] Display issues in Grads

Marjahn Finlayson mfinlayson at wesleyan.edu
Wed Dec 31 00:24:29 EST 2014


Thanks Thomas,

I tried both solutions and neither worked. The numbers on the xlab and ylab
are still not appearing. Even when I downloaded the new cbarn_black, the
color was only outlined in black. The numerical values remained missing.

Marjahn


On Mon, Dec 29, 2014 at 4:33 PM, Thomas Robinson <ter at hawaii.edu> wrote:

> Aloha Marjahn,
>
> The problem is you are using a white background with white letters and
> numbers.  There are two solutions:
>
> 1.  Using the latest version of GrADS fixed this problem for me.  When I
> used opengrads, I had this problem.
> 2.  Use the following commands:
> ** Set background to white
>
>        'set background 1'
> ** Clear to get the white background
>
> 'clear'
> *** Set strings to black
>        'set string 0'
> *** Set the map to black
>        'set map 0'
> *** Set the labels and title to black
>        'set annot 0'
>
> As for the cbar script, you need to kinda do the same thing.  I attached a
> modified cbarn script (cbarn_black.gs) that changes the the bar and
> numbers to black.
>
> I hope this is helpful!  I included the text of the cbarn_black script
> below.
>
> -Tom
>
> *
>
> *  Script to plot a colorbar
>
> *
>
> *  The script will assume a colorbar is wanted even if there is
>
> *  not room -- it will plot on the side or the bottom if there is
>
> *  room in either place, otherwise it will plot along the bottom and
>
> *  overlay labels there if any.  This can be dealt with via
>
> *  the 'set parea' command.  In version 2 the default parea will
>
> *  be changed, but we want to guarantee upward compatibility in
>
> *  sub-releases.
>
> *
>
> *
>
> * modifications by mike fiorino 940614
>
> *
>
> * - the extreme colors are plotted as triangles
>
> * - the colors are boxed in white
>
> * - input arguments in during a run execution:
>
> *
>
> * run cbarn sf vert xmid ymid
>
> *
>
> * sf   - scale the whole bar 1.0 = original 0.5 half the size, etc.
>
> * vert - 0 FORCES a horizontal bar = 1 a vertical bar
>
> * xmid - the x position on the virtual page the center the bar
>
> * ymid - the x position on the virtual page the center the bar
>
> *
>
> * if vert,xmid,ymid are not specified, they are selected
>
> * as in the original algorithm
>
> *
>
>
> function colorbar (args)
>
>
> sf=subwrd(args,1)
>
> vert=subwrd(args,2)
>
> xmid=subwrd(args,3)
>
> ymid=subwrd(args,4)
>
>
> if(sf='');sf=1.0;endif
>
>
> *
>
> *  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
>
>
>   ylolim=0.6*sf
>
>   xdlim1=1.0*sf
>
>   xdlim2=1.5*sf
>
>   barsf=0.8*sf
>
>   yoffset=0.2*sf
>
>   stroff=0.05*sf
>
>   strxsiz=0.12*sf
>
>   strysiz=0.13*sf
>
> *
>
> *  Decide if horizontal or vertical color bar
>
> *  and set up constants.
>
> *
>
>   if (ylo<ylolim & xd<xdlim1)
>
>     say "Not enough room in plot for a colorbar"
>
>     return
>
>   endif
>
>   cnum = subwrd(shdinfo,5)
>
> *
>
> * logic for setting the bar orientation with user overides
>
> *
>
>   if (ylo<ylolim | xd>xdlim1)
>
>     vchk = 1
>
>     if(vert = 0) ; vchk = 0 ; endif
>
>   else
>
>     vchk = 0
>
>     if(vert = 1) ; vchk = 1 ; endif
>
>   endif
>
> *
>
> * vertical bar
>
> *
>
>
>   if (vchk = 1 )
>
>
>     if(xmid = '') ; xmid = xhi+xd/2 ; endif
>
>     xwid = 0.2*sf
>
>     ywid = 0.5*sf
>
>
>
>     xl = xmid-xwid/2
>
>     xr = xl + xwid
>
>     if (ywid*cnum > ysiz*barsf)
>
>       ywid = ysiz*barsf/cnum
>
>     endif
>
>     if(ymid = '') ; ymid = ysiz/2 ; endif
>
>     yb = ymid - ywid*cnum/2
>
>     'set string 0 l 5'
>
>     vert = 1
>
>
>   else
>
>
> *
>
> * horizontal bar
>
> *
>
>
>     ywid = 0.4
>
>     xwid = 0.8
>
>
>     if(ymid = '') ; ymid = ylo/2-ywid/2 ; endif
>
>     yt = ymid + yoffset
>
>     yb = ymid
>
>     if(xmid = '') ; xmid = xsiz/2 ; endif
>
>     if (xwid*cnum > xsiz*barsf)
>
>       xwid = xsiz*barsf/cnum
>
>     endif
>
>     xl = xmid - xwid*cnum/2
>
>     'set string 0 tc 5'
>
>     vert = 0
>
>   endif
>
>
>
> *
>
> *  Plot colorbar
>
> *
>
>
>
>   'set strsiz 'strxsiz' 'strysiz
>
>   num = 0
>
>   while (num<cnum)
>
>     rec = sublin(shdinfo,num+2)
>
>     col = subwrd(rec,1)
>
>     hi = subwrd(rec,3)
>
>     if (vert)
>
>       yt = yb + ywid
>
>     else
>
>       xr = xl + xwid
>
>     endif
>
>
> *   Draw the left/bottom triangle
>
>     if (num = 0)
>
>       if(vert = 1)
>
>         xm = (xl+xr)*0.5
>
>         'set line 'col
>
>         'draw polyf 'xl' 'yt' 'xm' 'yb' 'xr' 'yt' 'xl' 'yt
>
>         'set line 0 1 5'
>
>         'draw line 'xl' 'yt' 'xm' 'yb
>
>         'draw line 'xm' 'yb' 'xr' 'yt
>
>         'draw line 'xr' 'yt' 'xl' 'yt
>
>       else
>
>         ym = (yb+yt)*0.5
>
>         'set line 'col
>
>         'draw polyf 'xl' 'ym' 'xr' 'yb' 'xr' 'yt' 'xl' 'ym
>
>         'set line 0 1 5'
>
>         'draw line 'xl' 'ym' 'xr' 'yb
>
>         'draw line 'xr' 'yb' 'xr' 'yt
>
>         'draw line 'xr' 'yt' 'xl' 'ym
>
>       endif
>
>     endif
>
>
> *   Draw the middle boxes
>
>     if (num!=0 & num!= cnum-1)
>
>       'set line 'col
>
>       'draw recf 'xl' 'yb' 'xr' 'yt
>
>       'set line 0 1 5'
>
>       'draw rec  'xl' 'yb' 'xr' 'yt
>
>     endif
>
>
> *   Draw the right/top triangle
>
>     if (num = cnum-1)
>
>       if (vert = 1)
>
>         'set line 'col
>
>         'draw polyf 'xl' 'yb' 'xm' 'yt' 'xr' 'yb' 'xl' 'yb
>
>         'set line 0 1 5'
>
>         'draw line 'xl' 'yb' 'xm' 'yt
>
>         'draw line 'xm' 'yt' 'xr' 'yb
>
>         'draw line 'xr' 'yb' 'xl' 'yb
>
>       else
>
>         'set line 'col
>
>         'draw polyf 'xr' 'ym' 'xl' 'yb' 'xl' 'yt' 'xr' 'ym
>
>         'set line 0 1 5'
>
>         'draw line 'xr' 'ym' 'xl' 'yb
>
>         'draw line 'xl' 'yb' 'xl' 'yt
>
>         'draw line 'xl' 'yt' 'xr' 'ym
>
>       endif
>
>     endif
>
>
> *   Put numbers under each segment of the color key
>
>     if (num < cnum-1)
>
>       if (vert)
>
>         xp=xr+stroff
>
>         'draw string 'xp' 'yt' 'hi
>
>       else
>
>         yp=yb-stroff
>
>        'draw string 'xr' 'yp' 'hi
>
>       endif
>
>     endif
>
>
> *   Reset variables for next loop execution
>
>     if (vert)
>
>       yb = yt
>
>     else
>
>       xl = xr
>
>     endif
>
>     num = num + 1
>
>   endwhile
>
> return
> ****************************************
>
> On Mon, Dec 29, 2014 at 11:05 AM, Stephen McMillan <
> smcmillan at planalytics.com> wrote:
>
>> Marjahn,
>>
>> The cbar script only does the color bar.  It would help if you also
>> included the portion of your script that sets up and generates the image,
>> otherwise it's difficult to reproduce and evaluate your issue.
>>
>> Stephen Mc
>>
>> On Mon, Dec 29, 2014 at 3:18 PM, Marjahn Finlayson <
>> mfinlayson at wesleyan.edu> wrote:
>>
>>> I normally would run cbar.gs script. I copied the script from the grads
>>> library displayed below:
>>>
>>> *
>>> *  Script to plot a colorbar
>>> *
>>> *  The script will assume a colorbar is wanted even if there is
>>> *  not room -- it will plot on the side or the bottom if there is
>>> *  room in either place, otherwise it will plot along the bottom and
>>> *  overlay labels there if any.  This can be dealt with via
>>> *  the 'set parea' command.  In version 2 the default parea will
>>> *  be changed, but we want to guarantee upward compatibility in
>>> *  sub-releases.
>>> *
>>> 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' 'hi
>>>       else
>>>         'draw string 'xr' '%(yb-0.05)%' 'hi
>>>       endif
>>>     endif
>>>     num = num + 1
>>>     if (vert); yb = yt;
>>>     else; xl = xr; endif;
>>>   endwhile
>>>
>>>
>>> On Sun, Dec 28, 2014 at 9:45 PM, Stephen McMillan <
>>> smcmillan at planalytics.com> wrote:
>>>
>>>> Yes, you should be able to do it for temperatures against time.
>>>> Regarding your "issue with running the char"...it would help if you
>>>> provided a sample of your script that has the issue, as well as the result
>>>> (image and/or screen result).  Otherwise, I would have to guess what you
>>>> mean.
>>>> Stephen
>>>>
>>>> On Sun, Dec 28, 2014 at 6:31 PM, <mfinlayson at wesleyan.edu> wrote:
>>>>
>>>>> I also have an issue with running the char. I can see the shaded
>>>>> colors but not the numerical values that correspond with them.
>>>>>
>>>>>
>>>>> On Dec 28, 2014, at 1:41 PM, Stephen McMillan <
>>>>> smcmillan at planalytics.com> wrote:
>>>>>
>>>>> Marjahn,
>>>>> Are you trying to plot lat/lon labels, or something else?  If lat/lon,
>>>>> and you're using nps or sps projection, you won't get them.  Use 'set mproj
>>>>> latlon' instead.  Otherwise, you can use 'draw string...' function to draw
>>>>> them.
>>>>> Stephen
>>>>>
>>>>> On Sun, Dec 28, 2014 at 1:26 PM, Marjahn Finlayson <
>>>>> mfinlayson at wesleyan.edu> wrote:
>>>>>
>>>>>> Hey everyone,
>>>>>>
>>>>>> I'm trying to plot data in grads, but the numerical labels in the
>>>>>> xlab and ylab do not appear whenever I create charts or maps.
>>>>>> I've tried the 'set xlab on' function and nothing's happened.
>>>>>> Help!
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> gradsusr mailing list
>>>>>> gradsusr at gradsusr.org
>>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> gradsusr mailing list
>>>>> gradsusr at gradsusr.org
>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> gradsusr mailing list
>>>>> gradsusr at gradsusr.org
>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> gradsusr mailing list
>>>> gradsusr at gradsusr.org
>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>
>>>>
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
>
> --
> Tom Robinson
> Treasurer - Graduate Student Organization
> Secretary - Student Athletic Fee Committee
> Graduate Student - Department of Atmospheric Science
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20141231/ae866f64/attachment-0001.html 


More information about the gradsusr mailing list