<div dir="ltr"><div class="gmail_default" style="font-size:small">Any graphical resource in NCL that ends in the word &quot;Color&quot; can be an integer value, a color name (&quot;blue&quot;), an RGB triplet (/1.,0.,0./), or an RGBA triplet (/1.,0.,0.,0.5/).</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">When you use an integer value, then NCL assumes you are using indexed color, so it queries your workstation to see what the current color map is associated with it, and uses the color associated with that index.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The problem in your case is that you have an array of 6 strings, and only four of them have valid color names. The others are empty:</div><div class="gmail_default"><br></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(0)    Red</span><br style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(1)    </span><br style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(2)    Blue</span><br style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(3)    Red</span><br style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(4)    Yellow</span><br style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">(5)  </span><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"> </span><br></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">The error message, </span><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">&quot;Unable to convert string &quot;&quot; to requested type&quot; is simply telling you that it doesn&#39;t recognize the color &quot;&quot;. If you have a blank color string, then this probably means that you had no values in that range, and hence you should skip that particular step.</span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">--Mary</span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-family:HelveticaNeue,&#39;Helvetica Neue&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></span></div><div class="gmail_default"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 20, 2015 at 9:56 AM, Geeta Geeta <span dir="ltr">&lt;<a href="mailto:geetag54@yahoo.com" target="_blank">geetag54@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_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>Thanks Alan and Mary for your help. <br></span></div><div dir="ltr"><span>Thanks Alan. I have tried your way of defining the colors. It worked but with some warnings. <br></span></div><div dir="ltr"><span>I am getting warning message because txFontColor is an integer while I am passing a string variable I guess. <br></span></div><div dir="ltr"><span>ariable: colors<br>Type: string<br>Total Size: 24 bytes<br>            6 values<br>Number of Dimensions: 1<br>Dimensions and sizes:    [6]<br>Coordinates: <br>Number Of Attributes: 1<br>  _FillValue :    missing<br>(0)    Red<br>(1)    <br>(2)    Blue<br>(3)    Red<br>(4)    Yellow<br>(5)    <br>fatal:CvtStringToColorIndex: Unable to convert string &quot;&quot; to requested type<br>warning:Error retrieving resource txFontColor from args - Ignoring Arg<br>fatal:CvtStringToColorIndex: Unable to convert string &quot;&quot; to requested type<br>warning:Error retrieving resource txFontColor from args - Ignoring Arg<br>aditya@agniilap:~/geeta/ncl$ </span></div><div dir="ltr"><span>Pls clarify this Point (txFontColor = integer)<br></span></div><div dir="ltr"><br><span></span></div><div dir="ltr"><span>Mary the script runs fine.  Thank you. <br></span></div><div dir="ltr"><span>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><br></span></div><div dir="ltr"><span>Thanks</span></div><span class="HOEnZb"><font color="#888888"><div> </div><div>Geeta.</div></font></span><div><div class="h5">  <br><div><br><br></div><div style="display:block"> <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 &lt;<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>&gt; wrote:<br> </font> </div>  <br><br> <div><div><div><div dir="ltr"><div style="font-size:small">Geeta,</div><div style="font-size:small"><br clear="none"></div><div style="font-size:small">Please email all follow-up questions to <a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>, and do not send them to me directly.</div><div style="font-size:small"><br clear="none"></div><div 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 style="font-size:small"><br clear="none"></div><div style="font-size:small"><div><font face="monospace, monospace">  range_bot = (/   0.1,   2.5,      7.5/)</font></div><div><font face="monospace, monospace">  range_top = (/   2.5,   7.5,     15.5/)</font></div><div><font face="monospace, monospace">  colors    = (/&quot;Blue&quot;, &quot;Red&quot;, &quot;Green&quot;/)</font></div><div><font face="monospace, monospace">  nranges   = dimsizes(range_bot)</font></div><div><span style="font-family:monospace,monospace">; </span><br clear="none"></div><div><span style="font-family:monospace,monospace">; Loop through each range and get the indices of                                     </span></div><div><span style="font-family:monospace,monospace">; all the values that fall in this range. These                                       </span></div><div><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><span style="font-family:monospace,monospace">;                                                                                    </span></div><div><font face="monospace, monospace">  do n=0,nranges-1</font></div><div><font face="monospace, monospace">    ii := ind(rf.ge.range_bot(n).and.rf.lt.range_top(n))</font></div><div><font face="monospace, monospace">    if(.not.any(ismissing(ii))) then</font></div><div><font face="monospace, monospace">      txres@txFontColor = colors(n)     ; set the color for this range</font></div><div><font face="monospace, monospace">      unqstr = unique_string(&quot;text&quot;)    ; generate a unique id for text object</font></div><div><font face="monospace, monospace">      plot@$unqstr$ = gsn_add_text(wks,plot,&quot; &quot;+sprintf(&quot;%9.4g&quot;,rf(ii)), \</font></div><div><font face="monospace, monospace">                                       lon(ii),lat(ii),txres)</font></div><div><font face="monospace, monospace">    end if</font></div><div><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><div><br clear="none"><div>On Mon, Oct 19, 2015 at 11:02 AM, Geeta Geeta <span dir="ltr">&lt;<a rel="nofollow" shape="rect" href="mailto:geetag54@yahoo.com" target="_blank">geetag54@yahoo.com</a>&gt;</span> wrote:<br clear="none"><blockquote 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> 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)),&quot;Blue&quot;,&quot;   &quot;)  ; This is a string variable<br clear="none">     93   colors = where(((rf.ge.2.5).and.(rf.lt.7.5)),&quot;Red&quot;,&quot;   &quot;)<br clear="none">     94 ;  colors = where(((rf.ge.7.5).and.(rf.lt.15.5)),&quot;Yellow&quot;,&quot;   &quot;)<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:[&quot;Execute.c&quot;: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" href="mailto:aditya@agniilap" target="_blank">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><font color="#888888"><br clear="none"></font></span></div><span><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></div></div></div></blockquote></div><br></div>