[ncl-talk] scatter plot w/ different markers

Alessandra Giannini alesall at iri.columbia.edu
Wed Feb 5 14:45:05 MST 2020


hello Adam, 

duh!!! It was the same exact query… Thank you for your patience!…

I do have a follow-up…
What I actually want to do is, given a 2-dimensional array, assign different markers to one dimension, and different colors to the other dimension.

Attached is a script that does not work — it does in terms of different markers, but not in terms of different colors…

Suppose my array is (/ 3,5 /) — 3 rows and 5 columns. I want each element in a row to be identified by a different marker, and different rows [repeating the same markers] to be different colors.

If I define a “colors” vector like this:

cols = (/ "green", "yellow", "red" /)
col2D = onedtond(cols,(/5,3/))
col2D!0 = "mkr"
col2D!1 = "col"
coll = ndtooned(col2D( col |:, mkr |:))

when I add either:

mkres at xyMarkerColors = col2D

or 

mkres at xyMarkerColors = cols

then each marker gets a color…
Whereas if I set:

mkres at xyMarkerColors = coll

then all points are one color, the first one in the array “cols”.

Is the only way to do this to use a do-loop, where I repeat your original suggestion to handle markers, and loop on the colors?

thanks again!
alessandra








> On Feb 3, 2020, at 6:46 PM, Adam Phillips <asphilli at ucar.edu> wrote:
> 
> Hi Alessandra,
> Thanks for sending an easy-to-run example of the issue you are facing. I replied to a similar query this past September:
> http://mailman.ucar.edu/pipermail/ncl-talk/2019-September/015579.html <http://mailman.ucar.edu/pipermail/ncl-talk/2019-September/015579.html>
> 
> In short, you have to create 2D arrays of the input x/y axis values, as xyMarkers will assign a different marker for an array dimensioned (M,N) for every index N. Using your example, the following modifications result in the desired marker changes:
> mkres = True
> mkres at xyMarkLineMode   = "Markers"
> mkres at xyMarkerSizeF     = 0.02           ; Marker size (default 0.01)
> mkres at xyMarkers = ispan(2,11,1)
> mkres at xyMonoMarker = False
> 
> tind2 = new((/dimsizes(tind),2/),typeof(tind))
> tind2(:,0) = (/ tind /)
> pind2 = new((/dimsizes(pind),2/),typeof(pind))
> pind2(:,0) = (/ pind /)
> 
> oplots = gsn_csm_xy(wks,pind2,tind2,mkres)  
> 
> Hope that helps!
> Adam
> 
> 
> On Mon, Feb 3, 2020 at 1:41 PM Alessandra Giannini via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
> 
> hello everyone,
> 
> I have a problem that has been nagging me for a while…
> Here it is in its simplified form — 
> I would like to make a scatter plot of two variables, with each point in the plot represented by a different marker, selected from this list of possible markers:
> <http://www.ncl.ucar.edu/Document/Graphics/Images/markers.png <http://www.ncl.ucar.edu/Document/Graphics/Images/markers.png>>
> 
> These are the plot resources I set:
> 
> mkres = True
> mkres at gsnDraw  = False                          ; need these to wait
> mkres at gsnFrame = False
> 
> mkres at xyMarkLineMode   = "Markers"
> mkres at xyMarkerSizeF     = 0.01           ; Marker size (default 0.01)
> mkres at xyMarkers = ispan(2,16,1) 
> 
> following various examples in plot types/scatter plots.
> 
> But instead of the expected different markers, I get the same marker, corresponding to the first value in “ispan(2,16,1)", for all points.
> Is there some "sticky” default resource that needs to be unset?
> 
> I am running NCL version 6.3.0
> 
> Attached are the entire script, and a sample output.
> 
> Your help is much appreciated — 
> 
> warm regards, alessandra
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
> 
> -- 
> Adam Phillips 
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ <http://www.cgd.ucar.edu/staff/asphilli/>   303-497-1726 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200205/d9e1b688/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test123.ncl
Type: application/octet-stream
Size: 910 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200205/d9e1b688/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200205/d9e1b688/attachment-0001.html>


More information about the ncl-talk mailing list