[ncl-talk] xy plot with bins
Adam Phillips
asphilli at ucar.edu
Thu Nov 12 10:34:38 MST 2020
Hi Debasish,
Yes, it is possible. I use gsn_histogram to bin my data for me, but then I
manually use gsn_csm_xy to draw the bars. This method gives me greater
control over the plot than if I had used gsn_histogram to plot. Here is a
sample of my coding:
hres = True
hres at gsnDraw = False
hres at gsnFrame = False
hres at gsnHistogramBinIntervals = fspan(-.1,.1,41)
plot = gsn_histogram(wks,model_runtrend,hres)
aa_h = plot at NumInBins*1.
aa_h!0 = "time"
aa_h&time = fspan(-.0975,.0975,40) ; these are the midpoint values of
the bins set above in gsnHistogramBinIntervals
delete([/plot/])
if (min(model_runtrend).le.min(hres at gsnHistogramBinIntervals
).or.max(model_runtrend).gt.max(hres at gsnHistogramBinIntervals)) then ;
make sure values are not outside bin range
print("AA trends outside histogram bin range, adjust bin range")
printMinMax(model_runtrend,0)
exit
end if
bres = True
bres at gsnDraw = False
bres at gsnFrame = False
bres at gsnYRefLine = 0.0
bres at gsnXYBarChart = True
bres at gsnXYBarChartColors = "red"
bres at trYMinF = 0.0
bres at trXMinF = -.1
bres at trXMaxF = .1
bres at tmXBMode = "Explicit"
bres at tmXBValues = fspan(-.1,.1,5)
bres at tmXBLabels = bres at tmXBValues
bres at tmXBMinorValues = fspan(-.2,.2,17)
bplot = gsn_csm_xy(wks, aa_h&time, aa_h, bres)
Hope that helps!
Adam
On Wed, Nov 11, 2020 at 11:54 PM Debasish Hazra via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Hi,
> Is there a way to do xy plot with size bins on xaxis without doing pdfx in
> NCL ? Attached is ncl script that reads output using pdfx. But wondering
> without using pdfx, can NCL be used to draw bins specified in xaxis.
> Uploaded output file in ftp server. Any help on this is appreciated.
>
> Thanks
> Debasish
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201112/0c46993e/attachment.html>
More information about the ncl-talk
mailing list