;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; test_histogram.ncl ; Carl Schreck (cjschrec@ncsu.edu) ; February 2015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Description: Trying to replicate some odd behavior with bin_sum ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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/shea_util.ncl" ;load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl" ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl" load "$CJS_NCL_LIB/lib.cjs_graphics.ncl" load "$CJS_NCL_LIB/print_clock.ncl" load "$CJS_NCL_LIB/sub.bin_sum_other.ncl" procedure plot_histogram( \ io_wks[1] : graphic, \ i_xData[*] : numeric, \ i_binMin[1] : numeric, \ i_binMax[1] : numeric, \ i_binWidth[1] : numeric \ ) begin ; plot_histogram print_clock( "bin_sum " + i_binMin + " " + i_binMax ) res = True res@gsnFrame = False res@gsnDraw = False nBin = 1 + round( ( i_binMax - i_binMin ) / i_binWidth, 3 ) res@gsnHistogramBinIntervals = fspan( i_binMin, i_binMax, nBin ) plot = gsn_histogram( io_wks, i_xData, res ) txRes = True txRes@txFontHeightF = 0.015 txRes@txJust = "BottomCenter" labels = tostring( plot@NumInBins ) dum1 = gsn_add_text(io_wks,plot,labels,plot@MidBarLocs,plot@NumInBins+1,txRes) draw(plot) frame(io_wks) end ; plot_histogram begin ; main print_clock( "Here we go!" ) ; These are some parameters that could be useful to have up top plotType = "pdf" plotName = "figures/test_histogram" plotDpi = 200 wks = gsn_open_wks( plotType, plotName ) fltData = random_normal( 0, 60, 1000 ) binMin = 0 binWidth = 5 do binMax = 20, 60, 5 plot_histogram( wks, fltData, binMin, binMax, binWidth ) end do intData = toint( fltData ) binMin = 0 binWidth = 5 do binMax = 20, 60, 5 plot_histogram( wks, intData, binMin, binMax, binWidth ) end do print_clock( "Thank you, come again." ) end; main