Re: How to put marker above the Geophysical Line

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 20 2012 - 14:10:05 MDT

Thanks for providing your script and data.

The problem is that inside your personal "gsn_csm_polymarker" function, you added
calls to "gsn_polymarker_ndc" and "gsn_text_ndc". When you call these two procedures,
the markers and text get drawn right at that point, and then later the map is drawn and
covers up what you just did. It doesn't matter what all the draw
resources are set to, because those resources only apply when you are *attaching*
markers and text to a plot via "gsn_add_polymarker" and "gsn_add_text".

The solution is to use the gsn_add_xxx functions instead of the gsn_xxxx_ndc procedures.

This makes things also a lot easier for panelling, because I see that you were trying
to figure out the correct NDC coordinates to use for each paneled plot.

What I did with your script was set "xleg" and "yleg" to the same locations
for each plot, used ndctodata to convert xleg/yleg to xlon/ylat, then
used gsn_add_xxxx to attach the information to the plot using xlon/ylat.

I've attached a modified version of your script. Note that it is a bit different
than the original because I had to replace the environment variable
references with actual paths.

Also, you may have to fix the x,y locations of the legend. I only took a guess at this.

--Mary

On Mar 20, 2012, at 10:37 AM, Ziqiang Jiang wrote:

> Hi,
>
> I'm sorry that it took up you much time. I set these resource, but it does not work
> for procedure gsn_text_ndc.
> mpres@mpFillOn = False
> mpres@mpGridAndLimbOn = True
> mpres@mpGridAndLimbDrawOrder = "Draw"
> mpres@mpGridSpacingF = 10.
> mpres@mpGridLineColor = "gray"
> mpres@mpGridLineDashPattern = 16
> mpres@mpOutlineBoundar ySets = "National"
> mpres@mpOutlineDrawOrder = "Draw"
> mpres@mpGeophysicalLineColor = "gray"
> mpres@mpGeophysicalLineThicknessF = .5
> mpres@mpNationalLineColor = "gray"
>
> You can look up and modify my scripts:
> /glade/home/zqjiang/scripts/verif2/mpsite_stat_f06.ncl
> /glade/home/zqjiang/scripts/verif2/submit.csh
> After modifying mpsite_stat_f06.ncl, ./submit.csh
>
> Thanks
>
> Ziqiang
>
>
> > From: haley@ucar.edu
> > Date: Tue, 20 Mar 2012 10:00:52 -0600
> > To: ziqiangj@yahoo.com.cn
> > CC: asphilli@ucar.edu; ncl-talk@ucar.edu
> > Subject: Re: [ncl- talk] How to put marker above the Geophysical Line
> >
> >
> > On Mar 20, 2012, at 9:47 AM, Ziqiang Jiang wrote:
> >
> > > Hi, Mary,
> > >
> > > I hope that legend is vertical to x axis. However longitude line is slanting for lamber projection,
> > > so I think that gsn_add_text is not fit. It seems that the resource "draw order" does not work
> > > for procedure "gsn_text_ndc". I don't know to solve this problem.
> >
> > Adam tried to explain the solution to this problem. You need to set the draw order resources
> > when you create the map, *not* when you call gsn_add_text or gsn_text_ndc.
> >
> > >
> > > In addition, function "gsn_add_text" can put text string above the Geophysical Line.
> >
> > I assume you meant to say "can't put the text string"?
> >
> > If you want your text string to completely cover up the geophysical outline, then you can try
> > fill ing in the background color of the text box. Try this script, which should draw the string
> > on top of the map:
> >
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> >
> > wks = gsn_open_wks("x11","blank_map")
> > res = True
> >
> > res@mpLimitMode = "LatLon"
> > res@mpMinLatF = 20
> > res@mpMaxLatF = 60
> > res@mpMinLonF = -120
> > res@mpMaxLonF = -60
> > res@mpFillOn = False
> >
> > res@gsnDraw = False
> > res@gsnFrame = False
> >
> > plot = gsn_csm_map_ce(wks,res)
> >
> > txres = True
> > txres@txFontHeightF = 0.015
> > txres@txPerimOn = True
> > txres@txBackgroundFillColor = "white"
> > txres@txPerimColor = "white"
> >
> > str = "this is a string drawn on top of the map"
> > txid = gsn_add_text(wks,plot,str,-90,25,txres)
> >
> > draw(plot)
> > frame(wks)
> >
> >
> > The same would apply if you are using gsn_text_ndc, but you need to make sure the map is drawn
> > *before* you call gsn_text_ndc.
> >
> > --Mary
> >
> > >
> > >
> > >
> > > > From: haley@ucar.edu
> > > > Date: Tue, 20 Mar 2012 09:11:04 -0600
> > > > To: ziqiangj@yahoo.com.cn
> > > > CC: asphilli@ucar.edu; ncl-talk@ucar.edu
> > > > Subject: Re: How to put marker above the Geophysical Line
> > > >
> > > > Ziqiang,
> > > >
> > > > I wanted to address your other comment about "gsn_add_text is not fit to add many text string to map".
> > > >
> > > > You can pass an array of text strings and X/Y locations for each string to gsn_add_text in one call. Here's an example:
> > > >
> > > > . . .
> > > > map = gsn_csm_contour_map(wks,data,res)
> > > > . . .
> > > > strings = (/"one","two","three"/)
> > > > lat = (/10,20,30/)
> > > > lon = (/90,90,90/)
> > > > txres =True
> > > > txres@txFontHeightF = 0.01
> > > > txid = gsn_add_text(wks,map,strings,lon,lat,txres)
> > > >
> > > > If you want each text string to be a different size, color, font, etc, then you will need to do this in a loop.
> > > >
> > > > --Mary
> > > >
> > > > On Mar 19, 2012, at 9:06 PM, Ziqiang Jiang wrote:
> > > >
> > > > > Hi, Adam
> > > > >
> > > > >
> > > > > Thanks for your advice.
> > > > > I'm sorry. I forgot to tell you that it does work for function "gsn_add_text"
> > > > > by using the resource "m pGridandLimbDrawOrder", but it does not work for
> > > > > function "gsn_text_ndc". I don't know why. However, function "gsn_add_text"
> > > > > is not fit to add many text string to m ap.
> > > > >
> > > > > Ziqiang
> > > > > From: asphilli@ucar.edu
> > > > > Date: Mon, 19 Mar 2012 20:16:29 -0600
> > > > > To: ziqiangj@yahoo.com.cn
> > > > > CC: ncl-talk@ucar.edu
> > > > > Subject: Re: How to put marker above the Geophysical Line
> > > > >
> > > > > Hi Ziqiang,
> > > > > Try setting mpGridandLimbDrawOrder = "Draw"
> > > > > http://www.ncl.ucar.edu/Document/Graphics/Resources/mp.shtml#mpGridAndLimbDrawOrder
> > > > >
> > > > > That resource controls the lat/lon grid lines, and is referenced at the top of the draw order page I sent you earlier. Note that you might have to experiment with the different DrawOrder resources to get things drawn in the order you desire. Hope that helps..
> > > > > Adam
> > > > >
> > > > > On Mar 19, 2012, at 7:22 PM, Ziqiang Jiang <zqjiang86@hotmail.com> wrote:
> > > > >
> > > > > Hi, Adam
> > > > >
> > > > > Thank you for help. With your help, I solve that problem.
> > > > > However, when I use "gsn_text_ndc", lon/lat line will lie above the "character" or "digit",
> > > > > as figure "dd.png" showed. I hope that lon/lat line will lie below the "character" or "digit",
> > > > > how to solve this problem?
> > > > >
> > > > > Ziqiang
> > > > >
> > > > > Date: Mon, 19 Mar 2012 17:23:00 -0600
> > > > > From: asphilli@ucar.edu
> > > > > To: ncl-talk@ucar.edu
> > > > > Subject: Re: [ncl -talk] How to put marker above the Geophysical Line
> > > > >
> > > > > Hi Ziqiang,
> > > > > See the draw order web page here:
> > > > > http://www.ncl.ucar.edu/Applications/draworder.shtml
> > > > >
> > > > > Assuming you are drawing the circle via a gsn_polymarker (or gsn_add_polymarker) call, you would set tfPolyDrawOrder = "PostDraw" within the resource list that you pass to gsn_polymarker. See examples #1 and 4 for examples of doing this with other polyline/polymarker/polygon dr awing examples..
> > > > >
> > > > > If that doesn't answer your query please respond to ncl-talk.
> > > > > Adam
> > > > >
> > > > > On 03/19/2012 05:01 PM, Ziqiang Jiang wrote:
> > > > > Hello,
> > > > >
> > > > > As figure showed, circle line was partly put below the Geophysical Line.
> > > > > ; And I don't know how to fully put marker above the Geophysical Line.
> > > > > who could tell me the resource for "mp"?
> > > > >
> > > > > Thank you very much
> > > > > Ziqiang
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > ncl-talk mailing list
> > > > > List instructions, subscriber options, unsubscribe:
> > > > >
> > > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > > >
> > > > > --
> > > > > ______________________________________________________________
> > > > > Adam Phillips
> > > > > asphilli@ucar.edu
> > > > >
> > > > > NCAR/Climate and Global Dynamics Division (303) 497-1726
> > > > > P.O. Box 3000
> > > > > Boulder, CO 80307-3000
> > > & gt; > http://www.cgd.ucar.edu/cas/asphilli
> > > > >
> > > > > _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > > > <dd.png>
> > > > > _______________________________________________
> > > > > ncl-talk mailing list
> > > > > List instructions, subscriber options, unsubscribe:
> > > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > > >
> > > > > _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > > > _______________________________________________
> > > > > ncl-talk mailing list
> > > > > List instructio ns, subscriber options, unsubscribe:
> > > ; > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > >
> > > > _______________________________________________
> > > > ncl-talk mailing list
> > > > List instructions, subscriber options, unsubscribe:
> > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > <ee.png><ff.png>_______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 20 14:10:25 2012

This archive was generated by hypermail 2.1.8 : Tue Mar 20 2012 - 15:27:15 MDT