[ncl-talk] Attaching a map outside (or inside) of a plot
Mary Haley
haley at ucar.edu
Thu Jul 9 12:10:01 MDT 2015
Hi Michele,
I'm CC-ing ncl-talk, as we prefer for people to post back to the list
rather than emailing developers individually.
Use gsn_add_text instead of gsn_text, in the same way you are using
gsn_add_polyline. Make sure you use a different id:
txid1 = gsn_add_text(wks,mapannotation,"A",lon(145,23),lat(145,23),tres)
txid2 = gsn_add_text(wks,mapannotation,"B",lon(145,79),lat(145,79),tres)
--Mary
On Thu, Jul 9, 2015 at 5:54 AM, Michele Petrini <mpetrini139 at yahoo.it>
wrote:
> Dear Mary,
> it works fine. Now I'm trying to add also two letters inside the legend
> plot (in order to label the polyline I drew), using the red code below;
>
> 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)
>
> tres = True
> tres at txFontHeightF = 0.01
> tres at txFontColor = "red"
>
> gsn_text(wks,mapannotation,"A",lon(145,23),lat(145,23),tres)
>
> gsn_text(wks,mapannotation,"B",lon(145,79),lat(145,79),tres)
>
> ypts = (/lat(145,25),lat(145,77)/)
> xpts = (/lon(145,25),lon(145,77)/)
>
> res2 = True
> res2 at gsLineColor = "red"
> res2 at gsLineThicknessF = 3.0
>
> dum = new(1,graphic)
> dum = gsn_add_polyline(wks,mapannotation,xpts(0:1),ypts(0:1),res2)
>
> amres = True
> amres at amParallelPosF = -0.55
> amres at amOrthogonalPosF = 0.97
> amres at amJust = "BottomLeft"
>
> map_final = gsn_add_annotation(isoplot,mapannotation,amres)
>
> resF = True
> resF at txString = "Isostasy profile over LIS"
> resF at txFont = 21
> resF at txFontHeightF = 0.03
>
> gsn_panel(wks,isoplot,(/1,1/),resF)
>
> What I get is the two letters A, B inside the main XYY plot. I really
> can't get why...
>
> Thank you,
> Michele
>
>
>
> On 08/07/2015 18:11, Mary Haley wrote:
>
> Michele,
>
> I think the error might be coming from trying to panel the "id" created
> from calling gsn_add_annotation, rather than the actual plot. Try this:
>
> gsn_panel(wks,isoplot,(/1,1/),False)
>
> You might also look into maximize_output
>
> --Mary
>
>
> On Wed, Jul 8, 2015 at 5:58 AM, Michele Petrini <mpetrini139 at yahoo.it>
> wrote:
>
>> 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
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> --
>
> ***
> 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/20150709/6b7758d0/attachment.html
More information about the ncl-talk
mailing list