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 |
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.2.0 : Wed May 14 2008 - 14:24:59 MDT