<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px"><div id="yui_3_16_0_1_1445250909914_25844"><span id="yui_3_16_0_1_1445250909914_26337">Thanks Alan and Mary for your help. <br></span></div><div dir="ltr" id="yui_3_16_0_1_1445250909914_26338"><span id="yui_3_16_0_1_1445250909914_26337">Thanks Alan. I have tried your way of defining the colors. It worked but with some warnings. <br></span></div><div id="yui_3_16_0_1_1445250909914_26482" dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">I am getting warning message because txFontColor is an integer while I am passing a string variable I guess. <br></span></div><div id="yui_3_16_0_1_1445250909914_26483" dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">ariable: colors<br class="" id="yui_3_16_0_1_1445250909914_26494">Type: string<br class="" id="yui_3_16_0_1_1445250909914_26496">Total Size: 24 bytes<br class="" id="yui_3_16_0_1_1445250909914_26498"> 6 values<br class="" id="yui_3_16_0_1_1445250909914_26500">Number of Dimensions: 1<br class="" id="yui_3_16_0_1_1445250909914_26502">Dimensions and sizes: [6]<br class="" id="yui_3_16_0_1_1445250909914_26504">Coordinates: <br class="" id="yui_3_16_0_1_1445250909914_26506">Number Of Attributes: 1<br class="" id="yui_3_16_0_1_1445250909914_26508"> _FillValue : missing<br class="" id="yui_3_16_0_1_1445250909914_26510">(0) Red<br class="" id="yui_3_16_0_1_1445250909914_26512">(1) <br class="" id="yui_3_16_0_1_1445250909914_26514">(2) Blue<br class="" id="yui_3_16_0_1_1445250909914_26516">(3) Red<br class="" id="yui_3_16_0_1_1445250909914_26518">(4) Yellow<br class="" id="yui_3_16_0_1_1445250909914_26520">(5) <br class="" id="yui_3_16_0_1_1445250909914_26522">fatal:CvtStringToColorIndex: Unable to convert string "" to requested type<br class="" id="yui_3_16_0_1_1445250909914_26524">warning:Error retrieving resource txFontColor from args - Ignoring Arg<br class="" id="yui_3_16_0_1_1445250909914_26526">fatal:CvtStringToColorIndex: Unable to convert string "" to requested type<br class="" id="yui_3_16_0_1_1445250909914_26528">warning:Error retrieving resource txFontColor from args - Ignoring Arg<br class="" id="yui_3_16_0_1_1445250909914_26530">aditya@agniilap:~/geeta/ncl$ </span></div><div id="yui_3_16_0_1_1445250909914_27115" dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">Pls clarify this Point (txFontColor = integer)<br class="" id="yui_3_16_0_1_1445250909914_26532"></span></div><div id="yui_3_16_0_1_1445250909914_26485" dir="ltr"><br><span id="yui_3_16_0_1_1445250909914_26337"></span></div><div id="yui_3_16_0_1_1445250909914_26765" dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">Mary the script runs fine. Thank you. <br></span></div><div id="yui_3_16_0_1_1445250909914_26779" dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">I did not intend to send a message to you directly but since many tabs were open. It happened by mistake. <br></span></div><div dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337"><br></span></div><div dir="ltr"><span id="yui_3_16_0_1_1445250909914_26337">Thanks</span></div><div id="yui_3_16_0_1_1445250909914_25842"> </div><div id="yui_3_16_0_1_1445250909914_25840" class="signature">Geeta.</div> <br><div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div dir="ltr"> <font face="Arial" size="2"> On Tuesday, 20 October 2015 12:32 AM, Mary Haley <haley@ucar.edu> wrote:<br> </font> </div> <br><br> <div class="y_msg_container"><div id="yiv4470089533"><div><div dir="ltr"><div class="yiv4470089533gmail_default" style="font-size:small;">Geeta,</div><div class="yiv4470089533gmail_default" style="font-size:small;"><br clear="none"></div><div class="yiv4470089533gmail_default" style="font-size:small;">Please email all follow-up questions to <a rel="nofollow" shape="rect" ymailto="mailto:ncl-talk@ucar.edu" target="_blank" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>, and do not send them to me directly.</div><div class="yiv4470089533gmail_default" style="font-size:small;"><br clear="none"></div><div class="yiv4470089533gmail_default" style="font-size:small;">You need to group the text strings by the color you want to render them in. So, you should be looping across the number of ranges you have, and not each value. Your code would look something like this:</div><div class="yiv4470089533gmail_default" style="font-size:small;"><br clear="none"></div><div class="yiv4470089533gmail_default" style="font-size:small;"><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> range_bot = (/ 0.1, 2.5, 7.5/)</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> range_top = (/ 2.5, 7.5, 15.5/)</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> colors = (/"Blue", "Red", "Green"/)</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> nranges = dimsizes(range_bot)</font></div><div class="yiv4470089533gmail_default"><span style="font-family:monospace, monospace;">; </span><br clear="none"></div><div class="yiv4470089533gmail_default"><span style="font-family:monospace, monospace;">; Loop through each range and get the indices of </span></div><div class="yiv4470089533gmail_default"><span style="font-family:monospace, monospace;">; all the values that fall in this range. These </span></div><div class="yiv4470089533gmail_default"><span style="font-family:monospace, monospace;">; are the values that should be drawn in the given </span><span style="font-family:monospace, monospace;">; ; color.</span></div><div class="yiv4470089533gmail_default"><span style="font-family:monospace, monospace;">; </span></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> do n=0,nranges-1</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> ii := ind(rf.ge.range_bot(n).and.rf.lt.range_top(n))</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> if(.not.any(ismissing(ii))) then</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> txres@txFontColor = colors(n) ; set the color for this range</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> unqstr = unique_string("text") ; generate a unique id for text object</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> plot@$unqstr$ = gsn_add_text(wks,plot," "+sprintf("%9.4g",rf(ii)), \</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> lon(ii),lat(ii),txres)</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> end if</font></div><div class="yiv4470089533gmail_default"><font face="monospace, monospace"> end do</font></div><div><br clear="none"></div><div><br clear="none"></div><div>See the attached script, which is based on your script, but using random data.</div><div><br clear="none"></div><div>--Mary</div><div><br clear="none"></div></div></div><div class="yiv4470089533yqt7336234235" id="yiv4470089533yqt68931"><div class="yiv4470089533gmail_extra"><br clear="none"><div class="yiv4470089533gmail_quote">On Mon, Oct 19, 2015 at 11:02 AM, Geeta Geeta <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:geetag54@yahoo.com" target="_blank" href="mailto:geetag54@yahoo.com">geetag54@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="yiv4470089533gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px;"><div><span></span></div><div dir="ltr"><span class="yiv4470089533"> Hi Mary. <br clear="none">I have tried three things for giving a range to the rainfall. Pls see the lines 91 to 110 of my script. <br clear="none"><br clear="none"><br clear="none"><br clear="none">1. I tried the following. <br clear="none"><br clear="none">1. print(nrf)<br clear="none"> 92 colors = where(((rf.ge.0.1).and.(rf.lt.2.5)),"Blue"," ") ; This is a string variable<br clear="none"> 93 colors = where(((rf.ge.2.5).and.(rf.lt.7.5)),"Red"," ")<br clear="none"> 94 ; colors = where(((rf.ge.7.5).and.(rf.lt.15.5)),"Yellow"," ")<br clear="none"> 95 ; colorss= stringtoint(colors)<br clear="none"> <br clear="none">2nd
Method in which I have defined the colors as an array. So there is
error on line 106. Also this will give an individual color to each data.
<br clear="none">Variable: colors<br clear="none">Type: integer<br clear="none">Total Size: 16 bytes<br clear="none"> 4 values<br clear="none">Number of Dimensions: 1<br clear="none">Dimensions and sizes: [4]<br clear="none">Coordinates: <br clear="none">(0) 1<br clear="none">(1) 21<br clear="none">(2) 41<br clear="none">(3) 61<br clear="none">fatal:Subscript out of range, error in subscript #0<br clear="none">fatal:An error occurred reading colors<br clear="none">fatal:["Execute.c":8578]:Execute: Error occurred at or near line 106 in file stn-v3.ncl<br clear="none"><br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:aditya@agniilap" target="_blank" href="mailto:aditya@agniilap">aditya@agniilap</a>:~/geeta/ncl$ <br clear="none"><br clear="none"></span>can U pls suggest???I also tried combining two statements with where but that did not work. <br clear="none"> Geeta. <br clear="none"><span class="yiv4470089533HOEnZb"><font color="#888888"><br clear="none"></font></span></div><span class="yiv4470089533HOEnZb"><font color="#888888"></font></span><div>Geeta.</div></div></div></blockquote></div><br clear="none"></div></div></div></div><br><br></div> </div> </div> </div></div></body></html>