[ncl-talk] showing range in bar plot
Debasish Hazra
debasish.hazra5 at gmail.com
Fri Mar 9 14:06:04 MST 2018
Thanks Rashed, it worked.
Debasish
On Fri, Mar 9, 2018 at 2:29 PM, Rashed Mahmood <rashidcomsis at gmail.com>
wrote:
> Hi Debasish,
> Try the following:
>
>
> begin
> arr = (/2569,7000,12.25,81.65,58.8/)
> minval = (/541,2190,7.83,49.33,38.88/)
> maxval = (/4006,10456,19.34,137.7,77.42/)
>
> wks_type = "x11"
> wname = "bar"
> wks = gsn_open_wks(wks_type,wname)
> ;************************************************
> ; create panel plots
> ;*************************************************
> res = True
> res at gsnDraw = False
> res at gsnFrame = False
> res at gsnXYBarChart = True ; plot mods desired
> res at trYMinF = 0
> res at trYMaxF = max(maxval)+0.1*max(maxval)
> lres = True ; polyline mods desired
> lres at gsLineColor = "black"
> lres at gsLineThicknessF = 2.5 ; thickness of lines
> lres at gsLineDashPattern = 0
> lres at gsLineColor = "gray50"
>
> plot = gsn_csm_xy(wks,ispan(1,5,1),arr,res)
>
> dum = new(dimsizes(arr),graphic)
> x = ispan(1,5,1)
> do n=0,dimsizes(dum)-1
> dum(n) = gsn_add_polyline(wks,plot,(/x(n),x(n)/),(/minval(n),maxval(
> n)/),lres)
> end do
> draw(plot)
> frame(wks)
> ;***********
> end
>
>
> Each y-error is drawn separately. There is also a simple function here for
> adding error bars (example 12):
> <https://www.ncl.ucar.edu/Applications/Scripts/scatter_12.ncl>
>
> https://www.ncl.ucar.edu/Applications/scatter.shtml
>
>
> Cheers,
> Rashed
>
>
>
>
> On Fri, Mar 9, 2018 at 10:56 AM, Debasish Hazra <debasish.hazra5 at gmail.com
> > wrote:
>
>> I am trying to do a barplot with vertical error bars that will show the
>> range. But the figure shows bars only, with any error bars associated. What
>> is needed to add error bars in the figure ?
>>
>> 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"
>> ;********************************************
>> begin
>> arr = (/2569,7000,12.25,81.65,58.8/)
>> minval = (/541,2190,7.83,49.33,38.88/)
>> maxval = (/4006,10456,19.34,137.7,77.42/)
>>
>> wks_type = "png"
>> wname = "bar"
>> wks = gsn_open_wks(wks_type,wname)
>> ;************************************************
>> ; create panel plots
>> ;*************************************************
>> res = True
>> res at gsnDraw = False
>> res at gsnFrame = False
>> res at gsnXYBarChart = True ; plot mods desired
>> lres = True ; polyline mods desired
>> lres at gsLineColor = "black"
>> lres at gsLineThicknessF = 2.5 ; thickness of lines
>> lres at gsLineDashPattern = 0
>> lres at gsLineColor = "gray50"
>>
>> plot = gsn_csm_xy(wks,ispan(1,5,1),arr,res)
>> dum = gsn_add_polyline(wks,plot,minval,maxval,lres)
>>
>> draw(plot)
>> frame(wks)
>> ;********************************************
>> end
>>
>> Thanks.
>> Debasish
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180309/da7572b0/attachment.html>
More information about the ncl-talk
mailing list