[ncl-talk] Two bar in one plot

Adam Phillips asphilli at ucar.edu
Fri Aug 1 16:33:20 MDT 2014


Hi Ipshita,
Please only respond to the ncl-talk list and not to me personally when
corresponding on NCL issues. That way the community can assist and/or see
whether an issue is resolved.

In your reply you stated "I did use two gsn_csm_xy plots in my code but
still it overlaps. I used the above example #9 to write it."

It does help all of us help you when you send the plot with the issue, and
in this case it revealed three things:

1) My initial response to you was correct: "You will want to adjust your
months array in your two gsn_csm_xy calls to be different from one another
as it is done in the example.  Otherwise your bars will overlap."  You are
inputting the exact same x-axis array into both gsn_csm_xy calls. That is
telling NCL to draw the bars in the *exact same location*. You will need to
alter your months array to account for this in one or both of your
gsn_csm_xy calls.

2) You may want to restrict the y-axis range of your plots. You can do this
by using the trYMinF and trYMaxF resources:
sres at trYMinF =  0.
sres at trYMaxF = 2800.

You will need to set trYMinF and trYMaxF for each plot separately.

3) You will likely have to adjust the Y-axis labels. See the bottom panel
of example #2 here: http://www.ncl.ucar.edu/Applications/tickmarks.shtml#ex2

Hope that helps. If not, please respond to the ncl-talk email list.
Adam




On Fri, Aug 1, 2014 at 3:56 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> Hi,
> I want to plot trend values and monthly means in one plot. Both are an
> array of size 12 .
> The program gives no error but the plot are overlapping. I am not sure how
> to fix it
> ;*****************************************************
> ;Trend and monthly climatology together in one bar plot
> ;*******************************************************
>
>      load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>      load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
>      months=(/1,2,3,4,5,6,7,8,9,10,11,12/)
>
>
> monthly_avg=asciiread("~/Documents/PhD_June_2015/NCL_Moonsoon/Data_output/Monthly_avg_air.txt",-1,
> "float")
>
> monthly_Trend=asciiread("~/Documents/PhD_June_2015/NCL_Moonsoon/Data_output/trend_air.txt",
> -1, "float")
>      printVarSummary(monthly_avg)
>
>      wks = gsn_open_wks("ps","Trend_Avg")
>
>
>      sres = True
>      sres at vpWidthF = 0.7
>      sres at vpHeightF = 0.5
>      sres at gsnDraw = True
>      sres at gsnFrame = False
>      sres at gsnXYBarChart = True
>      sres at gsnXYBarChartBarWidth = 0.15           ; change bar widths
>      sres at tmXBMode          = "Explicit"         ; explicit labels
>      sres at tmXBValues        = (/1,2,3,4,5,6,7,8,9,10,11,12/)
>      sres at tmXBLabels =
> (/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"/)
>      sres at tmXBLabelFontHeightF = 0.0205
>      sres at tmXTLabelFontHeightF = 0.0205
>      sres at tmYLLabelFontHeightF = 0.0225
>      sres at tiMainFontHeightF = 0.025
>      sres at tiMainFont = "helvetica"
>      sres at tiMainString = "All India Rainfall Climatology and Trend
> 1880-2012"
>      sres at tiYAxisString = "(mm)"
>
>      plot1 = gsn_csm_xy (wks,months,monthly_avg,sres)
>      sres at gsnXYBarChartColors = (/"red"/)                    ;
> seperately, not
>      plot2 = gsn_csm_xy(wks,months,monthly_Trend,sres)
>                ; advancing the frame
>      sres at gsnXYBarChartColors = (/"blue"/)                    ; but
> tweaking where
>
>
>      ;*******************************************************
>
> Can someone suggest what steps to take
> Ipshita
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Division, 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: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140801/0a5f4a20/attachment.html 


More information about the ncl-talk mailing list