Re: label the x-axis

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 05 2012 - 09:16:36 MST

We have several examples on our "panels" page that show how to do this.

For each plot that you create, you have to determine which ones get the bottom labels and which ones don't, and then set "res@tmXBLabelsOn" accordingly (True/False).

You might additionally need to set some special panel resources to help select which plot determines the sizing, because once you turn labels off on some of the plots, your plots are now different sizes.

See examples panel_7.ncl, panel_8.ncl, panel_14.ncl and panel_28.ncl for some examples at:

http://www.ncl.ucar.edu/Applications/panel.shtml

Example panel_28.ncl shows how to set gunPanelScalePlotIndex to change which plot is used to determine the sizing (by default, the first valid plot is used).

--Mary

On Nov 4, 2012, at 12:35 AM, Bidyut Bikash Goswami wrote:

> Hi, all
>
> I have a plot with 12 panels. I want to label the x-axis only for the bottom four panels.
>
> Please give me some suggestions on this. Thanks a lot.
>
> Below the code is given.
>
> Nabanita
> Senior Research Fellow
> Indian Institute Of Tropical Meteorology
> Climate & Global Modeling Division
> Dr. Homi Bhabha Road, Pashan
> Pune-411008
> Tel:+91-20-25904510
> email id: nabanitaborah@gmail.com ,
> nita@tropmet.res.in
>
>
>
>
>
>
>
>
>
>
> ;***********************************************************
> ; Plot Phase Space Diagram
> ;***********************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"
>
> begin
>
> dd=asciiread("daily_stdanom_rf_all.dat",(/7320,27/),"float")
>
>
> rf=dd(:,0)
> va=dd(:,1:
>
> dum= pdfxy(rf,va(:,0),0,0,False)
> dim=dimsizes(dum)
> nx=dim(1)
> ny=dim(0)
> nvar=26
> zz=new((/nvar,nx,ny/),typeof(dum))
> do i= 0 ,nvar-1
> print("var = "+i)
> dum2=pdfxy(rf,va(:,i),0,0,False)
> zz(i,:,=dum2
> delete(dum2)
> end do
>
> printVarSummary(zz)
>
> ;--------------------------------------------------
> ; ploting
> ;--------------------------------------------------
>
> plot = new (nvar, "graphic")
> wks = gsn_open_wks("eps","Bivariate_pdf_new")
> ; gsn_define_colormap(wks,"amwg") ; choose colormap
> gsn_define_colormap(wks,"gray")
>
> res = True
> res@gsnDraw = False
> res@gsnFrame = False
> res@cnInfoLabelOn = False
> res@cnFillOn = True
> res@lbLabelBarOn = False
> res@lbAutoManage = False
> res@tmYUseLeft = False ; Make right axis independent of left
> res@tmYROn = False ; Turn on right tickmarks
> res@tmXTOn = False ; Turn off top tickmarks
> res@cnLineLabelsOn = False ; turn off contour line labels
>
> res@tmXBMode = "Explicit"
> res@tmXBValues = (/-3,-2,-1,0,1,2,3,4/)
> res@tmXBLabels = (/"-3","-2","-1","0","1","2","3","4"/)
> res@tmYLMode = "Explicit"
> res@tmYLValues = (/-4,-2,0,2,4/)
> res@tmYLLabels = (/"-4","-2","0","2","4"/)
> res@tmYLMinorOn = False ; No minor tick marks.
> ; res@tmXBMinorOn = False ; No minor tick marks.
> res@tmXBMajorOutwardLengthF=0.0
> res@tmYLMajorOutwardLengthF=0.0
> ; res@tmYBMinorValues = ispan(-2,4,1)
>
> res@lbLabelStride=1
> res@trXMinF = -3.0 ; Limits for Y axis. The limits
> res@trXMaxF = 4.0 ; for the X axis will be different
>
>
> ;--------------------------------------------------
> ; Contour lines settings
>
> res@gsnSpreadColors = True ; use full color map
> res@gsnSpreadColorStart = 0
> res@gsnSpreadColorEnd = 102 ; don't use added gray
>
>
> ;--------------------------------------------------
> ; Add another text string. Y-axis label for each panel
> ;--------------------------------------------------
>
> txres = True ; text mods desired
> txres@txBackgroundFillColor = "White"
> txres@txFontHeightF = 0.03 ; font smaller. default big
> txres@txAngleF = 90.0 ; Rotate the text 90 deg. counter-clockwise.
>
> do i=0,nvar-1
>
> plot(i) = gsn_csm_contour (wks,zz(i,:,, res)
>
> amres = True
> amres@amParallelPosF =-0.48 ; This is the right edge of the plot.
> amres@amOrthogonalPosF =-0.26 ; This is the bottom edge of the plot.
> amres@amJust = "TopLeft"
>
> txid = gsn_create_text(wks, "Variable "+(i+1), txres)
>
> annoid = gsn_add_annotation(plot(i), txid, amres)
>
> end do
>
> ;--------------------------------------------------
> ; create panel
> ;--------------------------------------------------
> resP = True
> res@gsnPaperOrientation = "portrait"
> resP@gsnMaximize = False ; modify the panel plot
> resP@txString = ""
> resP@gsnPanelRowSpec = True ; tell panel what order to plt
> resP@pmLabelBarWidthF=0.5
> resP@lbLabelFontHeightF=0.007
> resP@gsnPanelLabelBar = True ; add common colorbar
>
> res@gsnPanelBottom = 0.3
> res@gsnPanelXWhiteSpacePercent = 5.
>
> ; gsn_panel(wks,plot,(/3,4,4,4,4,4,3/),resP)
> gsn_panel(wks,plot,(/4,4,4/),resP)
> print("plot = "+i)
>
> end
>
>
> ========================================
> _______________________________________________
> 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 Mon Nov 5 09:16:50 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 06 2012 - 15:05:49 MST