Re: Adding Marker on line

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 07 May 2008 17:20:22 -0600

Hi Louis,

I have been looking at your script, and with the help of others I think
I have come up with a solution for your legend at least.

You cannot draw marked lines using gsn_polyline (or gsn_add_polyline +
gsn_polyline_ndc for that matter). You can draw a polyline, and then
draw a polymarker on top of the line. You can find examples on how to
draw polymarkers on this applications page:
http://www.ncl.ucar.edu/Applications/polyg.shtml

Alternatively, you can just use gsn_legend_ndc, gsn_add_legend, or
gsn_create_legend.

Instead of this:
plot = gsn_csm_xy3(wks, lon, t, u, v, res1, res2, res3)
draw(plot)

sub in this:

plot = gsn_csm_xy3(wks, lon, t, u, v, res1, res2, res3)
draw(plot)

lres = True
lres_at_lgLineColors =(/"black","black","black"/)
lres_at_lgMonoMarkerIndex = False
lres_at_lgMarkerIndexes = (/6,11,16/)
lres_at_vpWidthF = 0.15 ; Change width and
lres_at_vpHeightF = 0.15 ; height of legend.
lres_at_lgPerimOn = False ; turn off box around
lres_at_lgLabelFontHeightF = .03 ; label font height
lres_at_lgDashIndexes = (/0,2,NhlNewDashPattern(wks, pattern3)/)

lres_at_lgLineThicknessF = 4.0
lres_at_lgLineLabelStrings = (/"","",""/) ; no labels in lines
lres_at_lgItemType = "MarkLines"
lres_at_lgMarkerColors = (/"black","black","black"/)
gsn_legend_ndc(wks,3,(/" T"," U"," V"/),0.2,0.8,lres)
frame(wks)
exit

You will have to alter some of the resources above, along with the
position of the legend to suit your needs.

With regards to the thickening of the 3rd Y-axis: I figured out that it
is happening when you set res3_at_xyLineThicknessF, and I am unsure why
that is the case. Unfortunately, I haven't come up with a work-around
yet. Hopefully one of the developers can look into this further.
Adam

louis Vonder wrote:
> Ncl users,
>
> Here attached a script I am using to plot xy_3 (i.e. one x-axis and
> three y-axis).
> I am trying to build my own legend, but I dont know how to add markers
> on lines.
>
> Secondly, markers appear on my third y-axis, I dont know why?
>
> Thanks for help
>
>
>
> ;*****************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;*****************************************************
> begin
> ; Create variables to contain data.
> ;
>
> data = asciiread("SMT", (/48, 6/), "float")
>
> xyz = new((/48, 3/), "float")
>
>
> u = data(:, 0)
> v = data(:, 1)
> t = data(:, 2)
>
> lon = fspan(1, 48, 48)
>
>
> wks = gsn_open_wks("eps","xy") ; Open an X11 workstation.
>
> res1 = True
> res2 = True
> res3 = True
>
>
> ; res1_at_tmXUseBottom = False ; Keep top axis independent of bottom.
> ; res1_at_tmXTLabelsOn = True ; have tick mark labels
> ; res1_at_tmXTOn = True ; have tick marks
>
>
> res1_at_tmXUseBottom = False ; Keep top axis independent of bottom.
> res1_at_tmXBLabelsOn = True ; have tick mark labels
> res1_at_tmXTOn = False ; have tick marks
>
>
> res1_at_tmXBMode = "Explicit" ; label independently
> res1_at_tmXBValues = (/2, 8, 14, 20, 26, 32, 38, 44/)
> res1_at_tmXBLabels = (/"12", "15", "18", "21", "00", "03", "06", "09"/)
>
>
>
> res1_at_gsnDraw = False ; don't draw yet
> res1_at_gsnFrame = False ; don't advance frame yet
>
>
> res1_at_vpHeightF = 0.4 ; change aspect ratio of plot
> res1_at_vpWidthF = 0.7
>
>
>
> res1_at_gsnMaximize = True
> res1_at_trXMaxF = max(lon) ; Control end of X axis
> res1_at_trXMinF = min(lon) ; Control end of X axis
>
> res1_at_tmXBLabelFontHeightF = 0.015
> res2_at_tmXBLabelFontHeightF = 0.015
> res3_at_tmXBLabelFontHeightF = 0.015
>
>
> res1_at_xyLineColor = "black" ; t
> res2_at_xyLineColor = "black" ; u
> res3_at_xyLineColor = "black" ; v
>
> res1_at_xyLineThicknesses = 3.0
> res2_at_xyLineThicknesses = 3.0
> res3_at_xyLineThicknesses = 3.0
>
> res1_at_xyDashPattern = 0.
> res2_at_xyDashPattern = 2.
>
> pattern3 = "$$$$______$$$$______$$$$______$$$$_____$$$$______"
>
> res3_at_xyDashPatterns = NhlNewDashPattern(wks, pattern3)
>
>
> res1_at_tiYAxisString = "t"
> res2_at_tiYAxisString = "u"
> res3_at_tiYAxisString = "v"
>
> res3_at_amOrthogonalPosF = 0.7 ; Move "v" axis line to right a little.
>
>
> res1_at_xyDashPattern = 0 ; Make curves all solid
> res1_at_xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res1_at_xyMarkers = (/6/) ; 3 different markers
> res1_at_xyMarkerColors = (/"black"/) ; 3 different colors
> res1_at_xyMarkerSizeF = 0.01
>
> res2_at_xyDashPattern = 0 ; Make curves all solid
> res2_at_xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res2_at_xyMarkers = (/11/) ; 3 different markers
> res2_at_xyMarkerColors = (/"black"/) ; 3 different colors
> res2_at_xyMarkerSizeF = 0.01
>
> res3_at_xyDashPattern = 0 ; Make curves all solid
> res3_at_xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res3_at_xyMarkers = (/16/) ; 3 different markers
> res3_at_xyMarkerColors = (/"black"/) ; 3 different colors
> res3_at_xyMarkerSizeF = 0.01
>
> ; Set up resources for a customized legend.
> ;
>
> labels = (/"t","u","v"/)
> nitems = dimsizes(labels) ; number of legend items
>
>
>
>
>
> plot = gsn_csm_xy3(wks, lon, t, u, v, res1, res2, res3)
> draw(plot)
>
> ; Manually create legend
> ;*****************************************************
> res_text = True ; text mods desired
> res_text_at_txFontHeightF = 0.015 ; change text size
> res_text_at_txJust = "CenterLeft" ; text justification
>
> res_lines = True ; polyline mods
> desired
>
> res_lines_at_gsLineDashPattern = 0. ; solid line
> res_lines_at_gsLineThicknessF = 5. ; line thicker
> res_lines_at_gsLineColor = "black" ; line color
> xx = (/2, 5/)
> yy = (/44, 44/)
>
> gsn_polyline(wks,plot, xx, yy, res_lines) ; add polyline
> gsn_text(wks,plot,"t", 6, 44, res_text); add text
> delete(xx)
> delete(yy)
>
> xx = (/2, 5/)
> yy = (/42, 42/)
> gsn_polyline(wks,plot, xx, yy, res_lines) ; add polyline
> gsn_text(wks,plot,"u", 6, 42, res_text); add text
> delete(xx)
> delete(yy)
>
> xx = (/2, 5/)
> yy = (/40, 40/)
> gsn_polyline(wks,plot, xx, yy, res_lines) ; add polyline
>
> gsn_text(wks,plot,"v", 6, 40, res_text); add text
>
>
>
>
> frame(wks) ; advance frame
>
>
> end
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> En finir avec le spam? Yahoo! Mail vous offre la meilleure protection
> possible contre les messages non sollicités
> http://mail.yahoo.fr Yahoo! Mail
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed May 07 2008 - 17:20:22 MDT

This archive was generated by hypermail 2.2.0 : Wed May 14 2008 - 14:24:59 MDT