Re: Adding Marker on line

From: louis Vonder <appopson_at_nyahnyahspammersnyahnyah>
Date: Thu, 8 May 2008 07:51:24 +0000 (GMT)
Many thanks Adam,

I applied modifications you suggest me, except the third axis, every thing is like I am trying to do.

I also read the message of Denis, perhaps Mary can tell me how to remove these markers on the third axis.

Thanks

--- En date de : Jeu 8.5.08, Adam Phillips <asphilli@cgd.ucar.edu> a écrit :
De: Adam Phillips <asphilli@cgd.ucar.edu>
Objet: Re: [ncl-talk] Adding Marker on line
À: "louis Vonder" <appopson@yahoo.fr>
Cc: "ncl forum" <ncl-talk@ucar.edu>
Date: Jeudi 8 Mai 2008, 1h20

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@lgLineColors =(/"black","black","black"/)
lres@lgMonoMarkerIndex = False
lres@lgMarkerIndexes = (/6,11,16/)
lres@vpWidthF = 0.15 ; Change width and
lres@vpHeightF = 0.15 ; height of legend.
lres@lgPerimOn = False ; turn off box around
lres@lgLabelFontHeightF = .03 ; label font height
lres@lgDashIndexes = (/0,2,NhlNewDashPattern(wks, pattern3)/)

lres@lgLineThicknessF = 4.0
lres@lgLineLabelStrings = (/"","",""/)
; no labels in lines
lres@lgItemType = "MarkLines"
lres@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@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@tmXUseBottom = False ; Keep top axis independent of bottom.
> ; res1@tmXTLabelsOn = True ; have tick mark labels
> ; res1@tmXTOn = True ; have tick marks
>
>
> res1@tmXUseBottom = False ; Keep top axis independent of bottom.
> res1@tmXBLabelsOn = True ; have tick mark labels
> res1@tmXTOn = False ; have tick marks
>
>
> res1@tmXBMode = "Explicit" ; label independently
> res1@tmXBValues = (/2, 8, 14, 20, 26, 32, 38, 44/)
> res1@tmXBLabels = (/"12", "15", "18",
"21", "00", "03", "06",
"09"/)
>
>
>
> res1@gsnDraw = False ; don't draw yet
> res1@gsnFrame = False ; don't advance frame
yet
>
>
> res1@vpHeightF = 0.4 ; change aspect ratio of plot
> res1@vpWidthF = 0.7
>
>
>
> res1@gsnMaximize = True
> res1@trXMaxF = max(lon) ; Control end of X axis
> res1@trXMinF = min(lon) ; Control end of X axis
>
> res1@tmXBLabelFontHeightF = 0.015
> res2@tmXBLabelFontHeightF = 0.015
> res3@tmXBLabelFontHeightF = 0.015
>
>
> res1@xyLineColor = "black" ; t
> res2@xyLineColor = "black" ; u
> res3@xyLineColor = "black" ; v
>
> res1@xyLineThicknesses = 3.0
> res2@xyLineThicknesses = 3.0
> res3@xyLineThicknesses = 3.0
>
> res1@xyDashPattern = 0.
> res2@xyDashPattern = 2.
>
> pattern3 = "$$$$______$$$$______$$$$______$$$$_____$$$$______"
>
> res3@xyDashPatterns = NhlNewDashPattern(wks, pattern3)
>
>
> res1@tiYAxisString = "t"
> res2@tiYAxisString = "u"
> res3@tiYAxisString = "v"
>
> res3@amOrthogonalPosF = 0.7 ; Move "v" axis line to right a
little.
>
>
> res1@xyDashPattern = 0 ; Make curves all solid
> res1@xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res1@xyMarkers = (/6/) ; 3 different markers
> res1@xyMarkerColors = (/"black"/) ; 3 different colors
> res1@xyMarkerSizeF = 0.01
>
> res2@xyDashPattern = 0 ; Make curves all solid
> res2@xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res2@xyMarkers = (/11/) ; 3 different markers
> res2@xyMarkerColors = (/"black"/) ; 3 different colors
> res2@xyMarkerSizeF = 0.01
>
> res3@xyDashPattern = 0 ; Make curves all solid
> res3@xyMarkLineMode = "MarkLines" ; Markers *and* lines
> res3@xyMarkers = (/16/) ; 3 different markers
> res3@xyMarkerColors = (/"black"/) ; 3 different colors
> res3@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@txFontHeightF = 0.015 ; change text size
> res_text@txJust = "CenterLeft" ; text
justification
>
> res_lines = True ; polyline mods
> desired
>
> res_lines@gsLineDashPattern = 0. ; solid line
> res_lines@gsLineThicknessF = 5. ; line thicker
> res_lines@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@ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

--
--------------------------------------------------------------
Adam Phillips asphilli@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

__________________________________________________
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
Received on Thu May 08 2008 - 01:51:24 MDT

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