function legend (xcent,ycent,font,numcaps,cap.1,line.1,mark.1,color.1,thick.1,cap.2,line.2,mark.2,color.2,thick.2,cap.3,line.3,mark.3,color.3,thick.3,cap.4,line.4,mark.4,color.4,thick.4,cap.5,line.5,mark.5,color.5,thick.5,cap.6,line.6,mark.6,color.6,thick.6,cap.7,line.7,mark.7,color.7,thick.7,cap.8,line.8,mark.8,color.8,thick.8,cap.9,line.9,mark.9,color.9,thick.9,cap.10,line.10,mark.10,color.10,thick.10) *---------------------------------------------------------------------------- * GrADS function to draw a legend * Bob Hart * Florida State University Meteorology * June 24, 1998 * * Arguments: * xcent = x-center location in inches of legend * ycent = y-center location in inches of legend * font = font size * numcaps = number of items in legend (maximum of 10) * cap.1 = Text caption in quotes for item 1 * line.1 = Line style for item 1 * mark.1 = mark type for item 1 (0 = no marker) * color.1 = line color for item 1 * thick.1 = line thickness for item 1 * cap.2 = Text caption in quotes for item 2 * line.2 = Line style for item 2 * mark.2 = mark type for item 2 (0 = no marker) * color.2 = line color for item 2 * thick.2 = line thickness for item 2 * . * . * . * repeat cap,line,mark,color, and thick for each item of numcaps * * Example function call: * * rc=legend(11,2,0.20,2,"Temperature",1,2,3,3,"Moisture",3,3,5,8) * * This would plot a legend with 2 items in the lower right corner of * a landscape page. * * NOTE: xsize (x-distance size of Legend) is default to 2.5". * If your text requires a thinner or wider legend, change xsize below. * * Legend title can be chaned by changing the variable 'legstr' * below. * *---------------------------------------------------------------------------- xsize=2.5 ysize=(numcaps+2)*font*1.25 XL = xcent-xsize/2 XR = xcent+xsize/2 YB = ycent-ysize/2 YT = ycent+ysize/2 legstr = "Legend" "set line 0" "draw recf "XL " " YB " " XR " " YT "set line 1" "draw rec "XL " " YB " " XR " " YT "set string 1 c" "set strsiz "font "draw string "xcent " " YT-0.1-font/2 " " legstr i=1 while (i <= numcaps) yloc=YT-font*1.25*(i+1) "set string 1 l" "set strsiz "font*0.75 "draw string " XL+0.1 " " yloc " " cap.i "set line "color.i " " line.i " " thick.i "draw line "XR-0.1 " " yloc " " XR-xsize/3 " " yloc "draw mark "mark.i " " XR-xsize/6 " " yloc " " font/2 i=i+1 endwhile