[pyngl-talk] label bars with map overlays

Mary Haley haley at ucar.edu
Thu Jan 21 10:07:14 MST 2016


Hi Judy,

The problem is that the map plot is being maximized in the screen before it
knows anything about the labelbar, and hence the labelbar associated with
the contour plot gets pushed off the right side of the screen.

The quick solution is to first remove this line:

mpres.pmLabelBarDisplayMode = 'Conditional'

and add a call to Ngl.maximize_plot right before Ngl.draw:

#overlay the two plots
Ngl.overlay(map_plot, iceContour)
Ngl.overlay(map_plot,iceVectors)

Ngl.maximize_plot(wks,map_plot)
Ngl.draw(map_plot)
Ngl.frame(wks)


This causes your map_plot to be resized to fit the screen/PS/PDF/PNG file.
The name of this call is a bit of a misnomer, because in this case it's
actually going to shrink the plot a little so it fits.

--Mary





On Wed, Jan 20, 2016 at 4:00 PM, Judy Twedt <judytwedt at gmail.com> wrote:

> Hi Mary and Pyngl users,
>
> I'm having trouble with labelbars on an overlay plot. I've overlaid a
> filled contour and a vector plot onto a map plot, and the only way I've
> been able to get the label bar to display is by setting mpres.pmLabelBarDisplayMode
> = 'Conditional' to the map resources.
>
>  The trouble is, now I have two label bars -- one which corresponds to the
> contour plot, and one generic and meaningless label bar. I've tried
> fiddling with the lbLabelBarOn switch in all of the resources to no avail.
> I would greatly appreciate any feedback on how to remove the generic label
> bar!
>
> Here is the code snippet.
> The file is on yellowstone
> at:/glade/p/work/jtwedt/cam4som/iceMotionAreaTrend.py
>
> wks = Ngl.open_wks('X11', 'overlay')
> rlist = Ngl.Resources()
> rlist.wkColorMap = 'precip4_diff_19lev'
> Ngl.set_values(wks, rlist)
>
> #instantiate resources
> mpres = Ngl.Resources()
> res = Ngl.Resources()
> vcres = Ngl.Resources()
>
> #turn off draw and drame
> mpres.nglDraw = False
> mpres.nglFrame = False
> res.nglDraw = False
> res.nglFrame = False
> vcres.nglDraw = False
> vcres.nglFrame = False
>
> #set up coordinate arrays
> res.sfXArray = lonT
> res.sfYArray = latT
> vcres.vfXArray = lonU
> vcres.vfYArray = latU
>
> # map resources
> mpres.mpOutlineOn           = True
> mpres.pmLabelBarDisplayMode = 'Conditional'
> #mpres.lbMonoFillPattern = True
> mpres.mpLimitMode = 'LatLon'
> mpres.trGridType = "TriangularMesh"
> mpres.mpCenterLatF = -79.
> mpres.mpMinLatF = -79.
> mpres.mpMaxLatF = -60.
> map_plot = Ngl.map(wks, mpres)
>
> #contour resources
> res.cnLineLabelsOn = False
> res.cnFillOn = True
> #res.lbLabelBarOn = True
> #res.tfPlotManagerOn = True
> res.cnLinesOn = False
> iceContour = Ngl.contour(wks, ice, res)
> #vector resources
> vcres.vcUseRefAnnoRes = True
> vcres.vcGlyphStyle = 'CurlyVector'
> #vcres.vcMinFracLengthF          = 0.33          # Increase length of
> vcres.vcMinMagnitudeF           = 1.0         # vectors.
> vcres.vcMinDistanceF =          0.02
> vcres.vcRefLengthF              = 0.04
> vcres.vcRefMagnitudeF           = 10.0
> #vcres.vcRefAnnoOn               = False
> iceVectors = Ngl.vector(wks, uvel, vvel, vcres)
>
> #overlay the two plots
> #map_plot.contour = iceContour.base
> Ngl.overlay(map_plot, iceContour)
> Ngl.overlay(map_plot,iceVectors)
> Ngl.draw(map_plot)
> Ngl.frame(wks)
> Ngl.end()
>
>
> --
> *Judy Twedt*
>
> *Graduate Student *
> *Department of Atmospheric Sciences*
> *University of Washington*
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20160121/21cf9aa0/attachment.html 


More information about the pyngl-talk mailing list