[ncl-talk] markers with different colors

Geeta Geeta geetag54 at yahoo.com
Fri Oct 23 13:10:11 MDT 2015


Hi all and MaryI am unable to do it and sorry for bothering you. 

I didnt get the concept behind adding a unique_string every time the gsn_add_polymarker is called as you have said. Kindly explain again.  I did try that but default markers (black) are plotted. 

This time I tried using where function as I had used before for plotting the text. here is the part of the script that I m trying along with the data. 
;---------Adding Markers & Coloring them according to the RF value
    nrf                      = dimsizes(rf)   
;    print(nrf)

    color_of_marker                 = new(nrf,string)
    dont_mark                           = "  "
    dont_mark at _FillValue     = "missing"
    color_of_marker   = where((rf.eq.0.0),dont_mark,dont_mark) 
    color_of_marker   = where(((rf.ge.0.1).and.(rf.lt.2.4)),"Green",dont_mark)
    color_of_marker   = where(((rf.ge.2.5).and.(rf.lt.7.5)),"Blue",dont_mark)
    color_of_marker   = where(((rf.ge.7.6).and.(rf.lt.35.5)),"Yellow",dont_mark)


printVarSummary(dont_mark)
print(color_of_marker)   ; Array of 295 strings is printed corresponding to RF value       
;

     res_mark                 = True
     res_mark at gsMarkerIndex   = 1  ; 17 predefined markers available
     res_mark at gsMarkerSizeF   = 0.012


     do n                     = 0,  nrf-1

    ;   if ((rf(n).ge.0.1).and.(rf(n).lt.2.5)) then

      res_mark at gsMarkerColor  = color_of_marker(n)
      str                     = unique_string("poly")
      plot@$str$              = gsn_add_polymarker(wks,plot,lon,lat,res_mark)
    
    end do
String variable "dont_mark" is not being converted to Color???? 
warning:Error retrieving resource gsMarkerColor from args - Ignoring Arg
fatal:CvtStringToColorIndex: Unable to convert string "  " to requested type
warning:Error retrieving resource gsMarkerColor from args - Ignoring Arg
fatal:CvtStringToColorIndex: Unable to convert string "  " to requested type
warning:Error retrievin

Thanks Geeta. 


     On Friday, 23 October 2015 3:33 AM, Mary Haley <haley at ucar.edu> wrote:
   

 [Please don't CC me on questions that are sent to ncl-talk.  I'm on ncl-talk, so I will see your follow-up messages.]
You need to have a unique identifier for each time you call gsn_add_xxxxx.
The easiest way to do this, without having to predefine an array to hold all the objects, is to use unique_string to generate a unique string name, and then use this string name as an attribute name.
So, instead of:     dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark)use:  str = unique_string("poly")  plot@$str$ = gsn_add_polymarker(wks,plot,lon,lat,res_mark)
--Mary



On Thu, Oct 22, 2015 at 12:37 PM, Geeta Geeta <geetag54 at yahoo.com> wrote:

Hi all. 
I was trying to give a different color to the rainfall range (value) recently. My actual data is some 300+ stations an when I run that script, the plot was all crowded . 

I thought of giving a different color to the marker itself without adding the text/rainfall value to the plot. 
here is that part ;---------Adding Markers according to rainfall value

  nrf                     = dimsizes(rf)
  markers                 = new(dimsizes(rf),string)
  dont_mark               = "red"

  res_mark                = True
  res_mark at gsMarkerIndex  = 1  ; 17 predefined markers available
  res_mark at gsMarkerSizeF  = 0.012
;  res_mark at gsMarkerColor = "black"

  do n                             = 0,  nrf-1
     if (rf(n).eq.0.0) then
      res_mark at gsMarkerColor       = "Black"
;     dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark)

        else if ((rf(n).ge.0.1).and.(rf(n).lt.2.4)) then
        res_mark at gsMarkerColor       = "Blue"

           else if ((rf(n).ge.2.5).and.(rf(n).lt.7.5)) then
           res_mark at gsMarkerColor  = "Red"
           end if
        end if
      end if
;  end do

     dum =gsn_add_polymarker(wks,plot,lon,lat,res_mark)
  end do
print(rf+res_mark at gsMarkerColor)
; ----------Now adding text--------------------I get warning like this and the Plot  has Only Black markers????
warning:TransformPostDraw: tfPolyDrawList element 273 is invalid
warning:TransformPostDraw: tfPolyDrawList element 274 is invalid
warning:TransformPostDraw: tfPolyDrawList element 275 is invalid
warning:TransformPostDraw: tfPolyDrawList element 276 is invalid
warning:TransformPostDraw: tfPolyDrawList element 277 is invalid
warning:TransformPostDraw: tfPolyDrawList element 278 is invalid
warning:TransformPostDraw: tfPolyDrawList element 279 is invalid
warning:TransformPostDraw: tfPolyDrawList element 280 is invalid
warning:TransformPostDraw: tfPolyDrawList element 281 is invalid
warning:TransformPostDraw: tfPolyDrawList element 282 is invalid
warning:TransformPostDraw: tfPolyDrawList element 283 is invalid
warning:TransformPostDraw: tfPolyDrawList element 284 is invalid
warning:TransformPostDraw: tfPolyDrawList element 285 is invalid
warning:TransformPostDraw: tfPolyDrawList element 286 is invalid
warning:TransformPostDraw: tfPolyDrawList element 287 is invalid
warning:TransformPostDraw: tfPolyDrawList element 288 is invalid
warning:TransformPostDraw: tfPolyDrawList element 289 is invalid
warning:TransformPostDraw: tfPolyDrawList element 290 is invalid
warning:TransformPostDraw: tfPolyDrawList element 291 is invalid
warning:TransformPostDraw: tfPolyDrawList element 292 is invalid
warning:TransformPostDraw: tfPolyDrawList element 293 is invalid
aditya at agniilap:~/geeta/ncl$ 
kindly suggest. 




  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/072a39e8/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stn-v5.ncl
Type: application/octet-stream
Size: 5830 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/072a39e8/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stn-v6.ps
Type: application/postscript
Size: 72899 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/072a39e8/attachment.ps 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rf-actual-23052013-mod.txt
Url: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/072a39e8/attachment.txt 


More information about the ncl-talk mailing list