[gradsusr] Question about COLA/IGES legend and lower title bar
Jennifer Adams
jma at cola.iges.org
Wed Jun 11 17:30:17 EDT 2014
Hi, Kevin --
I'm glad you are happy with version 2.1 and it didn't take too much work to incorporate gxprint. It is faster than writing out the metafile and running gxyat separately.
I have a set of background images with the topography that are a fixed size, that I am unable to re-create because of deprecated features in the imagemagik routine 'combine'. There probably is a way to do it with cairo, but I haven't had time to figure it out. So I am stuck with that image size and aspect ratio, unless I want to abandon the topography background, which I am not willing to do. I use mpvals to get the plot to fill the page and 'set parea 0 10.98 0 8.5'.
It can be tricky to get the mpvals just right to fill the page, but I am stuck with that technique because of the background image. There is a better way to do this -- draw the plot in the domain you want, use 'q gxinfo' to get the aspect ratio of the plot, then restart grads with -a using that ratio… But I digress.
The title bar is drawn on top of the finished graphic with 'draw recf', and the font is LiberationSans-Regular. The color fan has a big white mark (style 3) drawn underneath it to mask out the plot in the corner.
I create each panel using gxprint with -b and -t options, and then I use pngquant to shrink the filesize. ImageMagik is not a part of the operational scripts. The subroutine to draw the fan-shaped color bar is below. Note there are some global variables in there that will not work right if you run it as is.
--Jennifer
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Draws a fan-shaped color bar in the upper right corner
function carc(panel)
ro = 1.04 ;* outer radius for colors
ri = 0.50 ;* inner radius for colors
rt = 1.10 ;* radius for text
rti = 1.0 ;* radius for inner text
* xc,yc = coordinates of center of circle (a.k.a. the upper right hand corner of plot)
if (_regn='hemi' | _regn='shemi')
xc = 8.5
else
xc = 10.98
endif
yc = 8.5
* read the shading and contour info from _shades
ll = 1
data = sublin(_shades,1)
ll = subwrd(data,5)
mm = 1
while (mm <= ll)
mmp1 = mm + 1
data = sublin(_shades,mmp1)
col.mm = subwrd(data,1)
if (col.mm < 0)
col.mm = 999
endif
lim.mm = subwrd(data,3)
if (lim.mm = '>')
lim.mm = ' '
break
endif
mm = mm + 1
endwhile
* Cover up the corner of the plot
if (_regn!='hemi' & _regn!='shemi')
'set line 561' ; 'draw mark 3 'xc' 'yc' 2.8' ;* filled circle
'set line 1 1 3'; 'draw mark 2 'xc' 'yc' 2.8' ;* open circle outline
endif
* dd = amount of arc for colors to subtend (90deg)
* id = position on unit circle at which to start (270deg or bottom)
dd = 3.1415926*0.5/ll
id = 3.1415926*1.50
* calculate starting points
'd 'ro'*cos('id')' ; xfo = subwrd(result,4) + xc
'd 'ro'*sin('id')' ; yfo = subwrd(result,4) + yc
'd 'ri'*cos('id')' ; xfi = subwrd(result,4) + xc
'd 'ri'*sin('id')' ; yfi = subwrd(result,4) + yc
* For each color, calculate new points for color fills and text
mm = 1
while(mm<=ll)
id = id - dd
'd 'ro'*cos('id')' ; xlo = subwrd(result,4) + xc
'd 'ro'*sin('id')' ; ylo = subwrd(result,4) + yc
'd 'ri'*cos('id')' ; xli = subwrd(result,4) + xc
'd 'ri'*sin('id')' ; yli = subwrd(result,4) + yc
'd 'rt'*cos('id')' ; xft = subwrd(result,4) + xc
'd 'rt'*sin('id')' ; yft = subwrd(result,4) + yc
if (panel=7)
'd 'rti'*cos('id')'; xfti = subwrd(result,4) + xc
'd 'rti'*sin('id')'; yfti = subwrd(result,4) + yc
endif
did = id*180/3.1415926 - 180 ;* rotation angle for text
* Draw the color wedge
'set line 'col.mm
'draw polyf 'xfi' 'yfi' 'xfo' 'yfo' 'xlo' 'ylo' 'xli' 'yli
* Draw the contour values
ck = subwrd(lim.mm,1)
if (ck != '')
'set string 1 r 4 'did
'set strsiz 0.08 0.11'
if (panel=1 | (panel=3 & _tindx=1) | panel=4 | panel=5 )
* draw a label for every color wedge
'draw string 'xft' 'yft' 'lim.mm
endif
if (panel=2)
* draw label if it is divisible by 4
fmod = math_fmod(lim.mm,4)
if (fmod=0)
'draw string 'xft' 'yft' 'lim.mm
endif
* draw a thick black 540 line on the thickness plot
if (lim.mm=546)
'set line 1 1 4'
'draw line 'xfi' 'yfi' 'xfo' 'yfo
endif
endif
if (panel=3 & _tindx>1)
* draw selected precip contour levels
if (lim.mm=0.2 | lim.mm=1 | lim.mm=4 | lim.mm=8 | lim.mm=12 | lim.mm=18 | lim.mm=24 | lim.mm=30 | lim.mm=40 | lim.mm=50 | lim.mm=70 | lim.mm=90)
'set strsiz 0.08 0.10'
'draw string 'xft' 'yft' 'lim.mm
endif
endif
if (panel=6)
* draw selected pwat contour levels
if (lim.mm=6 | lim.mm=12 | lim.mm=18 | lim.mm=24 | lim.mm=30 | lim.mm=36 | lim.mm=42| lim.mm=48 | lim.mm=54 | lim.mm=60)
'draw string 'xft' 'yft' 'lim.mm
endif
endif
if (panel=7)
* draw interior text labels
if (lim.mm=3)
'set string 1 l 4 'did
if (_tindx=1)
'draw string 'xfti' 'yfti' 800mb'
else
'draw string 'xfti' 'yfti' LOW'
endif
endif
if (lim.mm=9)
'set string 1 l 4 'did
if (_tindx=1)
'draw string 'xfti' 'yfti' 500mb'
else
'draw string 'xfti' 'yfti' MID'
endif
endif
if (lim.mm=15)
'set string 1 l 4 'did
if (_tindx=1)
'draw string 'xfti' 'yfti' 300mb'
else
'draw string 'xfti' 'yfti' HIGH'
endif
endif
* draw low contour label
if (lim.mm=1 | lim.mm=7 | lim.mm=13)
'set string 1 r 4 'did
if (_tindx=1)
'draw string 'xft' 'yft' 70'
else
'draw string 'xft' 'yft' 50'
endif
endif
* draw high contour label
if (lim.mm=5 | lim.mm=11 | lim.mm=17)
'set string 1 r 4 'did
'draw string 'xft' 'yft' 90'
endif
endif
endif
xfo = xlo
yfo = ylo
xfi = xli
yfi = yli
mm = mm + 1
endwhile
'set string 1 l 1 0'
On Jun 11, 2014, at 4:29 PM, Kevin M Levey wrote:
> WED 11JUN14: 1320PDT
>
> This question is essentially for Jennifer Adams:
>
> I was wondering about a few items regarding your COLA/IGES images. Example:
>
> <avnmr1.00hr.png>
>
> Firstly, I am quite familiar with imagemagik to manipulate images etc, but was wondering
>
> 1] Are you cropping out everything outside the plot area to end up with your plot above and then adding (#2) the title bar below using imagemagik or is this new functionally in Grads 2.1 using gxprint -f, I’m thinking the latter ?
> The reason I ask, is that it appears the font in the lower title area is from GRADS and was wondering if you are adding this as shaded box in the plot area and then adding the text and then doing gxprint -f ?
>
> 2] Is the legend bar that you use (#1) COLA/IGES propriety code or freely available?
>
> One of the BEST new features of GRDs 2.1 is transparency and the ability to now plot different *shaded* layers.
>
> Thanks for the great upgrades!
>
> Regards,
>
> Kevin M Levey, MSc in Oceans and Atmospheric Sciences (University of Cape Town)
> Vice President of Operations
> CustomWeather, Inc.
> San Francisco, California, USA
>
> "Taking the World by Storm!"
>
> http://www.customweather.com
> http://www.myforecast.com
> http://www.1stweather.com
>
> cell: 415-794-0411
> work: 415-777-3566
> email: klevey at customweather.com
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
--
Jennifer M. Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
111 Research Hall, Mail Stop 2B3
George Mason University
4400 University Drive
Fairfax, VA 22030
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140611/199f2a68/attachment-0001.html
More information about the gradsusr
mailing list