[ncl-talk] markers with diff Colors.

Mary Haley haley at ucar.edu
Sun Oct 25 23:08:12 MDT 2015


Geeta,

For some reason, your messages keep ending up in my spam box. I've had
trouble with other yahoo.com addresses as well.

I sent you information on how to color markers given a range of values.
Did you not try this method?

You have code that looks like this:

      rf0                 =  ind(rf.eq.0.0)
      rf_range0           =  rf(rf0)
      nrf_range0          =  dimsizes(rf_range0)
;      print("rf0 output of ind(rf) while rf_range0 is actual value of rf"+
"    "+rf0+"     "+rf_range0)
      printVarSummary(rf_range0)

      rf1          =  ind(rf.ge.0.1.and.rf.lt.2.5)
      rf_range1    =  rf(rf1)
      nrf_range1   =  dimsizes(rf_range1)
;      print("rf1 output of ind(rf) while rf_range1 is actual value of rf"+
"    "+rf1+"     "+rf_range1)
      printVarSummary(rf_range1)

. . .

     do n                     = 0, nrf_range1-1
      res_mark at gsMarkerColor  = "red"
      str                     = unique_string("polymarker")
      plot@$str$              =
gsn_add_polymarker(wks,plot,lon,lat,res_mark)
    end do

You are looping through the number of index values that you found for each
range, but then calling gsn_add_polymarker and passing in the full array of
lat/lon points. Each do loop, then, is plotting the same set of markers
again, but with whatever color you set it to.

As I demonstrated in a previous example, you need to *subscript* lon and
lat with the index locations. There's no need to loop:

      res_mark at gsMarkerColor  = "blue"
      str                     = unique_string("polymarker")
      plot@$str$              =
gsn_add_polymarker(wks,plot,lon(rf0),lat(rf0),res_mark)

      res_mark at gsMarkerColor  = "red"
      str                     = unique_string("polymarker")
      plot@$str$              =
gsn_add_polymarker(wks,plot,lon(rf1),lat(rf1),res_mark)

​Notice how I subscripted your "lat" and "lon" arrays with "rf0" and then
"rf1".  These are the index values that you got by calling "ind".
​

​Please try to understand your code before sending it to ncl-talk.  You can
always add "print" statements to print out what's happening. For example,
you can print the values being sent to the gsn_add_polymarker routine by
typing:

       print(lat(rf1) + "/" + lon(rf1))
​
Also, if you have a new question, start a new "ncl-talk" thread and don't
simply keep tacking on new questions to old email threads. Before you post
new questions, however, try to find the answers on your own. You can find
some tips here:

http://www.ncl.ucar.edu/Support/posting_guidelines.shtml

​--Mary
​

On Sat, Oct 24, 2015 at 12:20 PM, Geeta Geeta <geetag54 at yahoo.com> wrote:

> I have a rainfall (1D array) and I had to plot those with diff colours
> depending on the range that I have defined.
>
> I have split my orginal array into smaller arrays and Now I am trying to
> give different COLORS to each array.
> This is some part of script
> ;----------Title res
>
>       res at tiMainString         = fili
>
>       plot = gsn_csm_map(wks,res)
> ;
> ;
> ;---------Adding Markers & Coloring them according to the RF value
>     nrf                      = dimsizes(rf)
> ;    print(nrf)
>
>      res_mark                 = True
>      res_mark at gsMarkerIndex   = 1     ; 17 predefined markers available
>      res_mark at gsMarkerSizeF   = 0.012
>
> ; Breaking up rf array into small arrays depending on their value
> ;
> ; ind fn return INDEX (in this case the line NOs when the below is TRUE)
> ;
>       rf0                 =  ind(rf.eq.0.0)
>       rf_range0           =  rf(rf0)
>       nrf_range0          =  dimsizes(rf_range0)
> ;      print("rf0 output of ind(rf) while rf_range0 is actual value of
> rf"+ "    "+rf0+"     "+rf_range0)
>       printVarSummary(rf_range0)
>
>       rf1          =  ind(rf.ge.0.1.and.rf.lt.2.5)
>       rf_range1    =  rf(rf1)
>       nrf_range1   =  dimsizes(rf_range1)
> ;      print("rf1 output of ind(rf) while rf_range1 is actual value of
> rf"+ "    "+rf1+"     "+rf_range1)
>       printVarSummary(rf_range1)
>
>       rf2            =  ind(rf.ge.2.5.and.rf.lt.7.5)
>       rf_range2      =  rf(rf2)
>       nrf_range2     =  dimsizes(rf_range2)
>       printVarSummary(rf_range2)
> ;      print("rf2 output of ind(rf) while rf_range2 is actual value of
> rf"+ "    "+rf2+"     "+rf_range2)
>
>       rf3            =  ind(rf.ge.7.5.and.rf.lt.35.5)
>       rf_range3      =  rf(rf3)
>       nrf_range3     =  dimsizes(rf_range3)
> ;      print("rf3 output of ind(rf) while rf_range3 is actual value of
> rf"+ "    "+rf3+"     "+rf_range3)
>       printVarSummary(rf_range3)
>
>       rf4            =  ind(rf.ge.35.5.and.rf.lt.64.5)
>       rf_range4      =  rf(rf4)
>       nrf_range4     =  dimsizes(rf_range4)
> ;      print("rf4 output of ind(rf) while rf_range4 is actual value of
> rf"+ "    "+rf4+"     "+rf_range4)
>       printVarSummary(rf_range4)
>
>
>
> do n                     = 0, nrf_range0-1
>       res_mark at gsMarkerColor  = "Blue"
>       str                     = unique_string("polymarker")
>       plot@$str$              =
> gsn_add_polymarker(wks,plot,lon,lat,res_mark)
>     end do
>
>      do n                     = 0, nrf_range1-1
>       res_mark at gsMarkerColor  = "red"
>       str                     = unique_string("polymarker")
>       plot@$str$              =
> gsn_add_polymarker(wks,plot,lon,lat,res_mark)
>     end do
>
> draw(plot)
> frame(wks)
>
> Following things I m not able to sort out and seek suggestions.
> 1. I get 227 values corresponding to Range0 (when rf=0.0) plotted in RED.
>                 Does it has to do it with draw function???
>
> 2. If I want to show the topography/ height of the region, how can I do
> that.
>
>
> thanks
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151025/5a325f8c/attachment.html 


More information about the ncl-talk mailing list