undef("circle_ll") procedure circle_ll(wks:graphic,plt:graphic,x0:numeric,y0:numeric,r:numeric,res:logical) ; Draws a circle (or ellipse) or radius (or x-axis length) r centered at (x0,y0). Optionally it can draw an ellipse and axes can be rotated as desired. ; Input Parameters: ; wks: graphics workstation ; plt: the plot graphics ; (x0,y0): center of the circle in terms of plot coordinate ; r: radius (or x-direction length) of the circle in terms of plot coordinate ; res: resources. If true can take any line graphic parameter valid to gsn_add_polyline. In addition, there are two special resources for this procedure: ; Scale: The scale by which the y-axis length should be modified to the x-axis length. This can be used to plot an ellipse. (default=1). ; Rotation: The rotation angle (in degrees) by which the axes are rotated (positive anticlockwhise). (default=0). ; ; Example: ;... ; arr=random_uniform(1,10,(/15,20/)) ; wks = gsn_open_wks("x11","circle"); ; res = True ; res@vpHeightF=0.5 ; res@vpWidthF=0.8 ; res@gsnDraw = False ; res@gsnFrame = False ; plt=gsn_csm_contour(wks,arr,res) ; resc=True ; resc@gsLineColor="red" ; resc@gsLineThicknessF=2 ; resc@Scale=1.5 ; resc@Rotation=-45 ; circle_ll(wks,plt,10,7,3,resc) ; draw(plt) ; frame(wks) ;... ; ; Author: Arindam Chakraborty ; begin rot = 0.0 scale = 1.0 th = ispan(0,360,1) pi = acos(-1.0) res1 = res if(res)then if(isatt(res,"Scale"))then scale = res@Scale delete(res1@Scale) end if if(isatt(res,"Rotation"))then rot = res@Rotation delete(res1@Rotation) end if end if getvalues plt "trXMinF":xmin "trXMaxF":xmax "trYMinF":ymin "trYMaxF":ymax "vpXF":vpx0 "vpYF":vpy1 "vpWidthF":vpw "vpHeightF":vph end getvalues rx = r/(xmax-xmin) ry = rx*vpw/vph xpts1 = cos(th*pi/180) ypts1 = sin(th*pi/180)*scale xpts2 = xpts1*cos(rot*pi/180) - ypts1*sin(rot*pi/180) ypts2 = xpts1*sin(rot*pi/180) + ypts1*cos(rot*pi/180) xpts = rx*xpts2*(xmax-xmin) + x0 ypts = ry*ypts2*(ymax-ymin) + y0 str = unique_string("circle_ll") plt@$str$ = gsn_add_polyline(wks,plt,xpts,ypts,res1) delete(str) delete(xpts1) delete(ypts1) delete(xpts2) delete(ypts2) delete(th) delete(res1) end