[ncl-talk] Attaching a map outside (or inside) of a plot

Michele Petrini mpetrini139 at yahoo.it
Wed Jul 8 04:58:03 MDT 2015


Dear helpdesk,
I am trying to attach a small map as a legend of a XY plot (with double 
different Y axes). The map I need to attach must contain also a line, 
added with gsn_add_polyline. The two single plots (the XYY plot and the 
map with the polyline) are correct (I drew them separately first), but 
as I use gsn_add_annotation I get the following error message:


fatal:Invalid plot ID=282 passed to NhlGetBB
warning:pmOverlaySequenceIds isn't a resource in this object
warning:NhlGetValues:Error retrieving pmOverlaySequenceIds
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 1927 in 
file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 6847 in 
file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 7546 in 
file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8578]:Execute: Error occurred at or near line 647 in 
file Exercise1.ncl

Do you have any idea the reason why I get such an error? Here is the code.

--------------------------------------------------------------------------------------------------------------------------------
;***************************************set resources for the isostasy 
plot (Left)

   resL                        = True

   resL at tiYAxisString          = "Variation in bedrock elevation (30-0 
kyrs BP) (m)"
   resL at tiXAxisFontHeightF     = 0.02
   resL at tiYAxisFontHeightF     = 0.02

   resL at xyLineColors           = 
20                                                   ; Define line colors.
   resL at xyLineThicknessF       = 
3.0                                                             ; Define 
line thickness.
   resL at xyDashPattern = 0 ; Make curves all solid

   resL at trYMaxF      = -150.
   resL at trYMinF      = -850.

   resL at tmXTOn                 = False

   resL at tmYLMinorOn            = False
   resL at tmYLLabelFont          = 21
   resL at tmYLLabelFontHeightF   = 0.02

   resL at pmLegendDisplayMode    = "Always"
   resL at lgPerimOn              = False
   resL at xyExplicitLegendLabels = "Topography variation (m)"
   resL at pmLegendSide           = "Bottom"
   resL at pmLegendOrthogonalPosF = 0.01
   resL at pmLegendWidthF         = 0.4
   resL at pmLegendHeightF        = 0.04

   resL at vpHeightF              = 0.4
   resL at vpWidthF               = 0.4


   resL at lgAutoManage = False
   resL at tmXBMode               = "Explicit" ; Define your own tick mark 
labels.
   ;resL at tmXBLabelFont          = 21 ; Change font of labels.
   ;resL at tmXBLabelFontHeightF   = 0.02
   resL at tmXBMinorOn            = False ; No minor tick marks.
   resL at tmXBValues             = (/xiso(0),xiso(52)/) ; Location to put 
tick mark labels
   resL at tmXBLabels             = (/"A","B"/)

   resL at gsnDraw                = False                   ; do not draw 
picture
   resL at gsnFrame               = False                   ; do not 
advance frame


;******************************************set resources for ice 
thickness plot (right)

    resR                        = True

    resR at tiYAxisString          = "Variation in ice thickness (30-0 kyrs 
BP) (m)"
    resR at tiXAxisFontHeightF     = 0.02
    resR at tiYAxisFontHeightF     = 0.02

    resR at xyLineColors           = 21 ; Define line colors.
    resR at xyLineThicknessF       = 3.0 ; Define line thickness.
    resR at xyDashPattern          = 1 ; Make curves all solid

    resR at trYMaxF      = 3100
    resR at trYMinF      = 600

    resR at tmXBOn                 = False
    resR at tmXTOn                 = False

    resR at tmYRMinorOn            = False
    resR at tmYRLabelFont          = 21
    resR at tmYRLabelFontHeightF   = 0.02

    resR at vpHeightF              = 0.4
    resR at vpWidthF               = 0.4


    resR at pmLegendDisplayMode    = "Always"
    resR at lgPerimOn              = False
    resR at xyExplicitLegendLabels = "Ice thickness variation (m)"
    resR at pmLegendSide           = "Bottom"
    resR at pmLegendOrthogonalPosF = 0.06
    resR at pmLegendWidthF         = 0.4
    resR at pmLegendHeightF        = 0.04
    resR at lgAutoManage = False
    resR at gsnDraw                = False                   ; do not draw 
picture
    resR at gsnFrame               = False                   ; do not 
advance frame


;******************************************set resources for legend plot
   res1          = True
   res1 at gsnDraw  = False
   res1 at gsnFrame = False


   res1 at mpLimitMode            = "Corners"            ; choose range of map
   res1 at mpLeftCornerLatF       = lat(41,1)
   res1 at mpLeftCornerLonF       = lon(41,1)
   res1 at mpRightCornerLatF      = lat(226,139)
   res1 at mpRightCornerLonF      = lon(226,139)

   res1 at mpProjection           = "LambertEqualArea"
   res1 at mpCenterLatF           = 90
   res1 at mpCenterLonF           = 0
   res1 at mpOutlineOn            = True
   res1 at tfDoNDCOverlay         = True

   res1 at cnFillOn               = True
   res1 at cnLevelSelectionMode   = "ManualLevels"
   res1 at cnMinLevelValF         = 0
   res1 at cnMaxLevelValF         = 5000
   res1 at cnLevelSpacingF        = 50
   res1 at gsnDraw                = False                  ; do not draw 
picture
   res1 at gsnFrame               = False                  ; do not advance 
frame

   res1 at cnLinesOn              = False                  ;  contour lines
   res1 at cnLineLabelsOn         = False                  ; no contour labels
   res1 at gsnSpreadColors        = True                   ; use total colormap
   res1 at gsnSpreadColorStart    = 2
   res1 at gsnSpreadColorEnd      = 27
   res1 at cnInfoLabelOn          = False                  ; no contour 
info (right bottom)
   res1 at lbLabelBarOn = False

   res1 at vpHeightF              = 0.2
   res1 at vpWidthF               = 0.2

;****************************************************end resources

   isoplot = 
gsn_csm_xy2(wks,xiso,brockplot1(25:77),icetplot1(25:77),resL,resR)

   mapannotation = gsn_csm_contour_map(wks,Hicetfmask(45:226,1:140),res1)

   ypts = (/lat(145,25),lat(145,77)/)
   xpts = (/lon(145,25),lon(145,77)/)

   res2                   = True
   res2 at gsLineColor       = "black"
   res2 at gsLineThicknessF  = 3.0
   res2 at gsLineLabelString = "A B"

   dum = new(1,graphic)
   dum = gsn_add_polyline(wks,mapannotation,xpts(0:1),ypts(0:1),res2)

   amres                        = True
   amres at amParallelPosF         = -1.15
   amres at amOrthogonalPosF         = -0.4
   amres at amJust                 = "CenterLeft"

   map_final = gsn_add_annotation(isoplot,mapannotation,amres)

   gsn_panel(wks,map_final,(/1,1/),False)

   delete(resL)
   delete(resR)
   delete(res1)
   delete(res2)
   delete(amres)
----------------------------------------------------------------------------------------------------------------------------------

Thank you for you help,

Michele

-- 

***
Michele Petrini

Ph.D. student in Earth Science and Fluid Mechanics

Università degli studi di Trieste,
Dipartimento di Matematica e Geoscienze
Palazzina C - via Weiss 1, 34128 Trieste, Italy

Email: mpetrini139 at yahoo.it
Skype: michele.petrins
Mobile: +39 3398367372

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150708/1712fb9f/attachment.html 


More information about the ncl-talk mailing list