[ncl-talk] add color dots to map
Adam Phillips
asphilli at ucar.edu
Fri Mar 6 11:09:03 MST 2015
Hi Yun,
Please always include ncl-talk on your replies so that other ncl-talk folks
can assist and also so the conversation gets saved in the ncl-talk archives
to assist future NCL users.
As my initial suggestion didn't solve the issue I created a sample script
that used your code snippet and tried to get it to do what you want. The
script and resulting graphics are attached.
I saw two issues that needed addressing:
1) Unless you created your own custom colormap or mistyped, there isn't a
colormap named WhAqGrYeOrReVi200. For my test case I switched to using
BkBlAqGrYeOrReViWh200.
2) The GetFillColor documentation states that the function is deprecated,
and to use either get_color_rgba or get_color_index. GetFillColor assigns
colors based on a scalar field, but uses the colors in the retrieved
colormap sequentially. For example, if you set up your cnLevels array =
(/5,10,15,20,25,30/), and are using the BkBlAqGrYeOrReViWh200 colormap, all
points less than 5 will be colored index 2 here:
http://www.ncl.ucar.edu/Document/Graphics/ColorTables/BkBlAqGrYeOrReViWh200.shtml
All points greater than or equal to 5 and less than 10 will be colored
index 3, and so on up to index 7. For this colormap, all those indices look
black.
What I think you want to do is to use get_color_index instead of
GetFillColor, as get_color_index assigns the colors in a fashion similar to
the manner that NCL spans colormaps for color-filled graphics. See the
documentation here:
http://www.ncl.ucar.edu/Document/Functions/Built-in/get_color_index.shtml
Hope that helps!
Adam
begin
x = ispan(190,290,20)
y = ispan(25,67,6)
pmvalue = ispan(2,32,5)
wks = gsn_open_wks("png", "overlay")
gsn_define_colormap(wks,"BkBlAqGrYeOrReViWh200")
res = True
res at gsnDraw = False
res at gsnFrame = False
res at mpFillOn = False
res at mpOutlineOn = True
res at mpLimitMode = "LatLon"
res at mpMinLatF = 20.
res at mpMaxLatF = 75.
res at mpMinLonF = 180.
res at mpMaxLonF = 300.
res at mpCenterLonF = 240.
plot = gsn_csm_map(wks,res)
cmap = gsn_retrieve_colormap(wks)
cnLevels = (/5,10,15,20,25,30/)
res_poly = True
res_poly at gsMarkerIndex = 16
res_poly at gsMarkerSizeF = 10
do i = 0, dimsizes(x)-1
res_poly at gsMarkerColor = get_color_index("BkBlAqGrYeOrReViWh200",cnLevels,
pmvalue(i))
print("Value = "+pmvalue(i)+" "+res_poly at gsMarkerColor)
dum = gsn_add_polymarker(wks, plot, x(i), y(i), res_poly)
str1 = unique_string("dum")
plot@$str1$=dum
end do
draw (plot)
frame(wks)
end
On Thu, Mar 5, 2015 at 3:53 PM, Yun Yue <yunyue at huskers.unl.edu> wrote:
>
> Hi NCL users,
>
> I'm trying to plot observation data to model simulated data map. I think I
> should use gsn_add_polymarker to overlay them. But for the @gsMarkerColor,
> I want use the same color for plotting simulated data map, so I tried to
> use code like the following. But I got black dots on the map. Can somebody
> help me to solve this? Thank you very much.
>
> Yun
>
> wks = gsn_open_wks("x11", "overlay")
>
> gsn_define_colormap(wks,"WhAqGrYeOrReVi200")
>
> cmap = gsn_retrieve_colormap(wks)
>
> cnLevels = (/5,10,15,20,25,30/)
>
> res_poly = True
>
> res_poly at gsMarkerIndex = 16
>
> res_poly at gsMarkerSizeF = 10
>
> do i = 0, station_numb
>
> res_poly at gsMarkerColor = GetFillColor(cnLevels, cmap, pmvalue(i))
> dum = gsn_add_polymarker(wks, plot, x, y, res_poly)
> str1 = unique_string("dum")
> plot@$str1$=dum
> end do
> draw (plot)
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Division, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150306/d26afb27/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overlay.png
Type: image/png
Size: 44261 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150306/d26afb27/attachment-0001.png
More information about the ncl-talk
mailing list