[ncl-talk] error: gsn_open_wks is undefined?

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Tue Aug 5 17:57:13 MDT 2014


Ipshita,

Please remove the semicolon in front of the first load statement in your
program.

--Dave


On Tue, Aug 5, 2014 at 5:38 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> Hi,
>
> I am trying to plot two bar plots in one common plot
> Here is the code. The error is gsn_open_wks is undefined. How do I
> approach this problem.
> Thank you in advance
>
>
> ;Trend and monthly Climatology together
> ;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/)
> x=asciiread("~/Documents/PhD_June_2015/NCL_Moonsoon/Data_output/Trend_monthly.txt",(/12,2/),
> "float")
>
> print(x)
>
> begin
>      npts   = 12
>      nplots = 2
>
> ;
> ; Define the x values for each set of bars to be slightly shifted
> ; so the bars don't overlap. The bars are shifted by 0.15 each
> ; which is what we'll use for the bar width later.
> ;
>      ii        = ispan(0,npts-1,1)
>      bar_width = 0.15
>      xarr      = new((/nplots,npts/),float)
>      do i=0,nplots-1
>        xarr(i,:) = ii+0.775 + (i*bar_width)
>      end do
>
>      colors           = (/"red","lightblue"/)
>      wks=gsn_open_wks("png","bar")
>
>      sres = True
>      sres at gsnDraw               = False
>      sres at gsnFrame              = False
>
>      sres at vpWidthF              = 0.7
>      sres at vpHeightF             = 0.5
>
>      sres at trXMinF               = min(xarr)-0.5    ; Leave some space
> before
>      sres at trXMaxF               = max(xarr)+0.5    ; and after bars.
>      sres at trYMinF               = 0.0
>      sres at trYMaxF               = max(stdarr)+.1   ; Leave some space at
> top
>
>      sres at gsnXYBarChart         = True
>      sres at gsnXYBarChartBarWidth = bar_width        ; make bar width
> smaller, otherwise
>                                                    ; they will overlap
>
>      sres at tmXBMode              = "Explicit"         ; explicit labels
>      sres at tmXBValues            = ispan(1,12,1)
>      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 gsnRightString        = ""
>      sres at tiYAxisString         = "Precipitation in mm"
>
> ;
> ; Loop through each plot, create it, and then overlay
> ; subsequent ones one the first one.
> ;
>      plots = new(nplots,graphic)
>      do i=0,1
>        sres at gsnXYBarChartColors = colors(i)
>        plots(i) = gsn_csm_xy(wks,xarr(i,:),x(:,i),sres)
>
>        if(i.gt.0) then
>          overlay(plots(0),plots(i))
>        end if
>      end do
>
> ;---Drawing plots(0) will also draw all the overlaid plots.
>     draw(plots(0))
>
>
>      frame(wks)   ; Advance the frame.
> end
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140805/91b01290/attachment.html 


More information about the ncl-talk mailing list