<div dir="ltr"><div><div>Hi, initially I found a script by Colleen at <a href="http://gradsusr.org/pipermail/gradsusr/2014-September/037452.html">http://gradsusr.org/pipermail/gradsusr/2014-September/037452.html</a> . After a little tweaks I come out with two scripts below. So I would like to ask for feedback on how to improve the scripts. Currently its two different scripts for the two different pole projections. I&#39;m planning to merge the two script together later on.<br>I also would like to figure out how to change the original degree East to degree East into degree East to degree West.<br></div>With regards to the Latitude labelling, I want to add a spacer/margin between the plot and the label (like what I did to the Longitude Labelling part), but this is quite hard. I could add some margin like   &#39;draw string &#39;xpos+0.1&#39; &#39;ypos-0.1&#39;  &#39;istart polelab, but this method is not dependant of the plotting angles. I just would like to add spaces before the numbers but GrADS don&#39;t register the spaces before that.<br></div>I have also not added the case where the plot is 0 to 360 degree East. <br><div><div><br></div><div>I would like to thank you in advance for any feedback.<br><br></div><div>* * * * * * * * * * * * * * * * * * * * * * * * * *<br>* Draws grid lines at specified intervals for South Pole Projection<br>* call is<br>* polargrid lonmin lonmax lonincr latmin latmax latincr<br>function polargrid(args)<br>* parse arguments<br>lonmin = subwrd(args,1)<br>lonmax = subwrd(args,2)<br>lonincr = subwrd(args,3)<br>latmin = subwrd(args,4)<br>latmax = subwrd(args,5)<br>latincr = subwrd(args,6)<br>&#39;q gxinfo&#39;<br>temp1 =sublin(result,6)<br>poleproj=subwrd(temp1,3)<br>*Determining how to label deg north or degree south.<br>if (poleproj&lt;3|poleproj&gt;4)<br> say &#39;This script is for plotting lat/lon label for pole projection only&#39; <br> return<br>else<br>if (poleproj=4)<br>polelab=&#39;`3.`0S&#39;<br>else<br>polelab=&#39;`3.`0N&#39;<br>endif<br>endif<br>*<br>midlat = (latmax+latmin)/2<br>quarterlat = (latmax+midlat)/2<br>&#39;q dims&#39;<br>xline = sublin(result,2)<br>yline = sublin(result,3)<br>lonstart = subwrd(xline,6)<br>lonend = subwrd(xline,8)<br>*midlon = (lonstart+lonend)/2<br>midlon = (lonmax+lonmin)/2<br>*For drawing the LATITUDE lablelling<br>*Currently the labelling is perpendicular to the plot side.  <br>*I think the ratio for the added margin needs to be based on the angle.<br>*The latitude labelling is quite hard to make it parallel to plot without cutting into the longitude labelling.<br>*You can also use while (istart &lt;=latmax-1) to skip the last latitude labelling for reasons of its out of plotting area (especially if you use panels) and/or it overlap with LONGITUDE labelling.<br>istart=latmin<br>angle=midlon-lonmax<br>while (istart &lt;=latmax)<br>  &#39;q w2xy &#39;lonmax&#39; &#39; istart <br>  xpos=subwrd(result,3)<br>  ypos=subwrd(result,6)<br>  &#39;set string 1 l 1 &#39;angle<br>  &#39;set strsiz 0.12&#39;<br>  &#39;draw string &#39;xpos&#39; &#39;ypos&#39; &#39;istart-istart-istart polelab<br>  istart=istart+latincr<br>endwhile<br>*For drawing the LONGITUDE lablelling<br>*Can be improved to provide the East and West labelling.<br>istart=lonmin<br>angle=midlon-lonmin<br>while (istart &lt;=lonmax)<br>  &#39;q w2xy &#39;istart&#39; &#39; latmax+((latmax-latmin)*0.03)<br>  xpos=subwrd(result,3)<br>  ypos=subwrd(result,6)<br>  &#39;set strsiz 0.12&#39;<br>  &#39;set string 1 bc 1 &#39;angle<br>  &#39;draw string &#39;xpos&#39; &#39;ypos&#39; &#39;istart&#39;`3.`0&#39;<br>  angle=angle-lonincr<br>  istart=istart+lonincr<br>endwhile<br>return<br><br>* * * * * * * * * * * * * * * * * * * * * * * * * *<br>* Draws grid lines at specified intervals for North Pole Projection.<br>* call is<br>* polargrid lonmin lonmax lonincr latmin latmax latincr<br>function polargrid(args)<br>*{}//No effect, just to preserve highlighting under ATOM.<br>* parse arguments<br>lonmin = subwrd(args,1)<br>lonmax = subwrd(args,2)<br>lonincr = subwrd(args,3)<br>latmin = subwrd(args,4)<br>latmax = subwrd(args,5)<br>latincr = subwrd(args,6)<br>&#39;q gxinfo&#39;<br>temp1 =sublin(result,6)<br>poleproj=subwrd(temp1,3)<br>*Determining how to label deg north or degree south.<br>if (poleproj&lt;3|poleproj&gt;4)<br> say &#39;This script is for plotting lat/lon label for pole projection only&#39; <br> return<br>else<br>if (poleproj=4)<br>polelab=&#39;`3.`0S&#39;<br>else<br>polelab=&#39;`3.`0N&#39;<br>endif<br>endif<br>*<br>midlat = (latmax+latmin)/2<br>quarterlat = (latmax+midlat)/2<br>&#39;q dims&#39;<br>xline = sublin(result,2)<br>yline = sublin(result,3)<br>lonstart = subwrd(xline,6)<br>lonend = subwrd(xline,8)<br>*midlon = (lonstart+lonend)/2<br>midlon = (lonmax+lonmin)/2<br>*For drawing the LATITUDE lablelling<br>*Currently the labelling is perpendicular to the plot side.  <br>*I think the ratio for the added margin needs to be based on the angle.<br>*The latitude labelling is quite hard to make it parallel to plot without cutting into the longitude labelling.<br>*You can also use while (istart &lt;=latmax-1) to skip the last latitude labelling for reasons of its out of plotting area (especially if you use panels) and/or it overlap with LONGITUDE labelling.<br>istart=latmin<br>angle=midlon-lonmin<br>while (istart &lt;=latmax)<br>  &#39;q w2xy &#39;lonmax&#39; &#39; istart <br>  xpos=subwrd(result,3)<br>  ypos=subwrd(result,6)<br>  &#39;set string 1 l 1 &#39;angle<br>  &#39;set strsiz 0.12&#39;<br>  &#39;draw string &#39;xpos&#39; &#39;ypos&#39;  &#39;istart polelab<br>  istart=istart+latincr<br>endwhile<br>*For drawing the LONGITUDE lablelling<br>*Can be improved to provide the East and West labelling.<br>istart=lonmin<br>angle=midlon-lonmax<br>while (istart &lt;=lonmax)<br>  &#39;q w2xy &#39;istart&#39; &#39; latmin-((latmax-latmin)*0.03)<br>  xpos=subwrd(result,3)<br>  ypos=subwrd(result,6)<br>  &#39;set strsiz 0.12&#39;<br>  &#39;set string 1 tc 1 &#39;angle<br>  &#39;draw string &#39;xpos&#39; &#39;ypos&#39; &#39;istart&#39;`3.`0&#39;<br>  angle=angle+lonincr<br>  istart=istart+lonincr<br>endwhile<br>return<br><br></div></div></div>