[ncl-talk] gsn_polyline and shading issue
Cathy Smith (NOAA Affiliate)
cathy.smith at noaa.gov
Tue Aug 5 13:35:12 MDT 2014
David
Thanks. I believe I understand the issue now. If you use
gsn_add_polyline it works. If you use gsn_ployline, it works if you put
it after the draw(map) as it is immediately drawing (unlike the
gsn_add_polyline ).
Sorry for the confusion. I didn't understand the difference between the
two routines but do now.
Cathy
On 8/4/14 5:15 PM, David Brown wrote:
> You do not need to set any "DrawOrder" resources to get what you want.
> I think the issue here is the ordering of the calls. gsn_polyline is
> an immediate mode call, meaning that it draws as soon as it is called.
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat1,poly_lat1/),pres)
>
> gsn_polyline(wks,map,(/poly_lon2,poly_lon2/),(/poly_lat1,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat2,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon1/),(/poly_lat1,poly_lat2/),pres)
>
> draw(map)
>
> This sequence of calls draws 4 polylines and then draws the map. If
> you want the lines on top, you should just put the draw(map) call
> before the polyline calls.
> (The frame call should not be commented out, but It should be placed
> after the polyline calls.):
>
> draw(map)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat1,poly_lat1/),pres)
>
> gsn_polyline(wks,map,(/poly_lon2,poly_lon2/),(/poly_lat1,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat2,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon1/),(/poly_lat1,poly_lat2/),pres)
>
> frame(wks)
>
>
> On the other hand, if you use gsn_add_polyline you are adding the
> polylines as components of the "map" graphic object. The lines are
> drawn when you call draw(map). So in this case,
> you do need to have the polyline calls in front of the draw(map) call:
>
> d1 =
> gsn_add_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat1,poly_lat1/),pres)
>
> d2 =
> gsn_add_polyline(wks,map,(/poly_lon2,poly_lon2/),(/poly_lat1,poly_lat2/),pres)
>
> d3 =
> gsn_add_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat2,poly_lat2/),pres)
>
> d4 =
> gsn_add_polyline(wks,map,(/poly_lon1,poly_lon1/),(/poly_lat1,poly_lat2/),pres)
>
> draw(map)
> frame(wks)
>
> Hope this helps.
> -dave
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Mon, Aug 4, 2014 at 3:25 PM, Adam Phillips <asphilli at ucar.edu
> <mailto:asphilli at ucar.edu>> wrote:
>
> Hi Cathy,
> That is strange. I would think the res at mpFillDrawOrder = "Draw"
> and pres at tfPolyDrawOrder = "PostDraw" combination would definitely
> work. I just tried running things here, and I was able to plot the
> polylines over the map fill by swapping gsn_polyline for
> gsn_add_polyline.
>
> I'm not sure why one would have to do that; perhaps a developer
> can chime in here.
> Adam
>
>
> On Mon, Aug 4, 2014 at 3:13 PM, Cathy Smith - NOAA Affiliate
> <cathy.smith at noaa.gov <mailto:cathy.smith at noaa.gov>> wrote:
>
> Adam
> I tried that and got the same behavior (lines behind shading)
>
> Cathy
>
>
>
>
>
>
> On Mon, Aug 4, 2014 at 3:08 PM, Adam Phillips
> <asphilli at ucar.edu <mailto:asphilli at ucar.edu>> wrote:
>
> Hi Cathy,
> Try setting pres at tfPolyDrawOrder = "PostDraw". That
> resource should control when the polylines are drawn. If
> that doesn't solve it let everyone know.
> Adam
>
>
> On Mon, Aug 4, 2014 at 3:01 PM, Cathy Smith - NOAA
> Affiliate <cathy.smith at noaa.gov
> <mailto:cathy.smith at noaa.gov>> wrote:
>
> I tried res at mpFillDrawOrder (which I think is what
> you were referring to; the other doesn't exist)
>
> I set to PreDraw, Draw and Post Draw and got the same
> behavior. I did see some doc here
>
> http://www.ncl.ucar.edu/Applications/draworder.shtml
>
> which is along the lines of what you suggested but
> didn't seem to work for the routines I used. I wonder
> if there is a way to draw the polylines last instead
> of the shaded fill first?
>
> Thanks for the suggestion.
>
> Cathy
>
>
> On Mon, Aug 4, 2014 at 2:43 PM, Kyle Griffin
> <ksgriffin2 at wisc.edu <mailto:ksgriffin2 at wisc.edu>> wrote:
>
> I believe the quick fix, assuming nothing else is
> explicitly ordered, will be
>
> res at mpDrawOrder = "PreDraw"
>
> If that doesn't do it, you can poke around with
> other DrawOrder resources to move things into
> either "PreDraw", "Draw", or "PostDraw" drawing
> phases.
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2 at wisc.edu
> <mailto:ksgriffin2 at wisc.edu>
>
>
> On Mon, Aug 4, 2014 at 3:28 PM, Cathy Smith (NOAA
> Affiliate) <cathy.smith at noaa.gov
> <mailto:cathy.smith at noaa.gov>> wrote:
>
> Hi NCLers
> I'm having trouble getting a polyline to
> appear OVER a map with
> continents shaded. I have simplified code
> below which reproduces the
> problem. The code draws a basic map (shading
> is default) and then a box
> on the map using gsn_polyline . You can run
> code and then look at
> fluffy.ps <http://fluffy.ps>. The box just
> shows up where there is no shading. I verified
> in testing that the lines show up as long as
> they aren't located where
> the shading is. How can I control the order of
> shading so it is done
> before the polylines?
>
> NCL version is 6.2.0 on a 64 bit linux server.
>
> Thanks!
> Cathy Smith
>
>
> ;*;************************************************
> load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load
> "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;**************************************************
> begin
>
> psname="fluffy"
> wks = gsn_open_wks("ps",psname)
> ; open workstation
> res = True
> ; map resources
> res at gsnDraw = False
> ; don't draw
> res at gsnFrame = False
> ; don't advance frame
> res_lb = True
> ; map resources
> latmin=41
> latmax=52
> lonmin=235
> lonmax=250
> poly_lat1=43
> poly_lat2=50
> poly_lon1=237
> poly_lon2=247
> res at mpMaxLatF = latmax
> ; select subregion
> res at mpMinLatF = latmin
> res at mpMinLonF = lonmin
> res at mpMaxLonF = lonmax
> res at mpCenterLonF = (lonmax+lonmin)/2.
>
> map = gsn_csm_map_ce(wks,res)
> ; create map
>
> pres = True
> ; polyline
> resources
> pres at gsLineThicknessF = 2.0
> ; line thickness
>
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat1,poly_lat1/),pres)
>
> gsn_polyline(wks,map,(/poly_lon2,poly_lon2/),(/poly_lat1,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon2/),(/poly_lat2,poly_lat2/),pres)
>
> gsn_polyline(wks,map,(/poly_lon1,poly_lon1/),(/poly_lat1,poly_lat2/),pres)
>
> draw(map)
> ; frame(wks)
>
> end
>
> --
> ----------------------------------------------
> NOAA/ESRL PSD and CU CIRES
> 303-497-6263 <tel:303-497-6263>
> http://www.esrl.noaa.gov/psd/people/cathy.smith/
>
> Emails about data/webpages may get quicker
> responses from emailing
> esrl.psd.data at noaa.gov
> <mailto:esrl.psd.data at noaa.gov>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options,
> unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
>
> --
>
> ---------------------------------------------------
> NOAA/ESRL PSD and CIRES CDC
> 303-497-6263 <tel:303-497-6263>
> http://www.esrl.noaa.gov/psd/people/cathy.smith/
>
> Emails about data/webpages may get quicker responses from emailing
>
> esrl.psd.data at noaa.gov <mailto:esrl.psd.data at noaa.gov>
>
>
> _______________________________________________
> 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/
> <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
> <tel:303-497-1726>
>
>
>
>
> --
>
> ---------------------------------------------------
> NOAA/ESRL PSD and CIRES CDC
> 303-497-6263 <tel:303-497-6263>
> http://www.esrl.noaa.gov/psd/people/cathy.smith/
>
> Emails about data/webpages may get quicker responses from emailing
>
> esrl.psd.data at noaa.gov <mailto:esrl.psd.data at noaa.gov>
>
>
>
>
> --
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Division, NCAR
> www.cgd.ucar.edu/staff/asphilli/
> <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
> <tel:303-497-1726>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
----------------------------------------------
NOAA/ESRL PSD and CU CIRES
303-497-6263
http://www.esrl.noaa.gov/psd/people/cathy.smith/
Emails about data/webpages may get quicker responses from emailing
esrl.psd.data at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140805/cca60cb0/attachment.html
More information about the ncl-talk
mailing list