[pyngl-talk] vertical axis in cross section plot

Mary Haley haley at ucar.edu
Fri Oct 19 09:23:42 MDT 2018


Hi Matt,

Check out the PyNGL gallery and see the irregular.py example:

http://www.pyngl.ucar.edu/Examples/gallery.shtml

I think you need to set:

resources.nglYAxisType = "LinearAxis"

which may seem counterintuitive, but what this says is to linearize the Y
axis such that the irregular values on this axis are linearly spaced. The
example above graphically shows what this looks like.

--Mary


On Thu, Oct 18, 2018 at 6:09 PM, Fearon, Dr. Matthew, Contractor, Code 7533
via pyngl-talk <pyngl-talk at ucar.edu> wrote:

> Dear PyNgl users,
>
>
>
> I’m trying to plot a vertical cross section with regional model data on
> the native terrain-following vertical coordinate, in my case, that
> coordinate is sigma height. The levels are *not* equally spaced. However,
> when I plot the data, the vertical spacing between the levels is by default
> assumed to be equally spaced, at least it appears that way. Please see
> attached cross section plot, and in particular, the values on the vertical
> axis. How can I plot this properly such that the levels are not assumed to
> be equally spaced? Below is my plotting code where I use sfYArray to define
> my vertical axis/increment. I thought this approach with sfYArray would
> accommodate the unequal spacing, but it does not. I’ve explored a bit
> trYAxisType = IrregularAxis, but have been unsuccessful in getting it work.
>
>
>
> Also, here are my vertical levels stored in the variable “yl” used in the
> plotting routine.
>
> [5.0, 15.0, 26.0, 38.0, 50.0, 62.0, 75.0, 89.0, 104.0, 120.0, 137.0,
> 155.0, 174.0, 195.0, 218.0, 242.0, 267.0, 294.0, 323.0, 353.0, 385.0,
> 419.0, 455.0, 494.0, 535.0, 578.0, 624.0, 673.0, 725.0, 780.0, 838.0,
> 900.0, 966.0, 1036.0, 1111.0, 1195.0, 1288.0, 1391.0, 1506.0, 1634.0,
> 1776.0, 1934.0, 2110.0, 2306.0, 2525.0, 2769.0, 3040.0, 3342.0, 3678.0,
> 4052.0, 4469.0, 4933.0, 5449.0, 6023.0, 6662.0, 7373.0, 8164.0, 9045.0,
> 10026.0, 11118.0, 12333.0, 13685.0, 15190.0, 16865.0, 18729.0, 20804.0,
> 23114.0, 25685.0, 28546.0, 31730.0]
>
>
>
>
>
> Thanks for the help,
>
> Matt
>
>
>
>
>
>
>
> def map_vslice(pname,plabel,cvarone,cvartwo,u,v,xv,xl,yv,yl,yd):
>
>
>
>     wks_type = "png"
>
>     wks = Ngl.open_wks(wks_type, pname)
>
>
>
>     #cmap                        = Ngl.read_colormap_file("
> WhiteBlueGreenYellowRed")
>
>     #cmap                        = Ngl.read_colormap_file("MPL_PuOr")
>
>     #cmap                        = Ngl.read_colormap_file("MPL_PuBu")
>
>     cmap                        = Ngl.read_colormap_file("MPL_Greens")
>
>     #cmap                        = cmap[::-1,:]
>
>     #cmap                        = Ngl.read_colormap_file("cmocean_tempo")
>
>     #cmap                        = Ngl.read_colormap_file("
> WhiteYellowOrangeRed")
>
>
>
>     cfres                       = Ngl.Resources()
>
>     cfres.nglFrame              = False
>
>     cfres.nglDraw               = False
>
>     clres                       = Ngl.Resources()
>
>     clres.nglFrame              = False
>
>     clres.nglDraw               = False
>
>
>
>     ylimit                      = max(yl) #)-12
>
>     cfres.sfXArray              = xv
>
>     cfres.sfYArray              = yl
>
>     clres.sfXArray              = xv
>
>     clres.sfYArray              = yl
>
>
>
>     #For Y axis
>
>     cfres.tmYLMode              = "Explicit"
>
>     cfres.tmYLLabelFont         = "times-roman"
>
>     cfres.tmYLValues            = yl[::5]
>
>     cfres.tmYLLabels            = yl[::5]
>
>     cfres.tmYLMinorOn           = True
>
>     cfres.tmYLMinorValues       = yl
>
>
>
>
>
>     #For X axis
>
>     cfres.tmXBMode              = "Explicit"
>
>     cfres.tmXBLabelFont         = "times-roman"
>
>     cfres.tmXBValues            = xv[::20]
>
>     cfres.tmXBLabels            = xl[::20]
>
>     cfres.tmXBMinorOn           = True
>
>     cfres.tmXBMinorValues       = xv[::5]
>
>
>
>     cfres.tmXBLabelFontHeightF  = 0.006
>
>     cfres.tmYLLabelFontHeightF  = 0.006
>
>
>
>
>
>     clres.cnFillOn              = False
>
>     clres.cnLinesOn             = True
>
>     clres.cnLineColor           = "Black"
>
>     clres.cnLineThicknessF      = 3
>
>     clres.cnLineLabelsOn        = True
>
>     clres.cnLineLabelFontHeightF= 0.007
>
>     clres.cnLineLabelPerimOn    = False
>
>     clres.cnLineLabelBackgroundColor = -1
>
>     clres.cnInfoLabelOn         = False
>
>
>
>
>
>     cfres.tmXBLabelFontHeightF  = 0.007
>
>     cfres.tmYLLabelFontHeightF  = 0.007
>
>     cfres.tiYAxisString         = "Sigma-Height/m"
>
>     cfres.tiXAxisString         = "Latitude/deg"
>
>     cfres.tiXAxisFontHeightF    = 0.012
>
>     cfres.tiYAxisFontHeightF    = 0.012
>
>     cfres.tiMainOn              = True
>
>     cfres.tiMainFontHeightF     = 0.013
>
>
>
>     cfres.cnFillOn              = True
>
>     cfres.cnLinesOn             = False
>
>     cfres.cnLineLabelsOn        = False
>
>     cfres.cnFillPalette         = cmap
>
>
>
>     cfres.lbAutoManage          = True #False
>
>     cfres.lbLabelStride         = 1
>
>     cfres.pmLabelBarWidthF      = 0.02
>
>     cfres.lbLabelFontHeightF    = 0.016
>
>     cfres.lbPerimThicknessF     = 2
>
>     cfres.pmLabelBarOrthogonalPosF = 0.002
>
>
>
>     plot = Ngl.contour(wks,cvarone,cfres)
>
>     oplot= Ngl.contour(wks,cvartwo,clres)
>
>     Ngl.overlay(plot,oplot)
>
>
>
>
>
>     Ngl.draw(plot)
>
>     Ngl.frame(wks)
>
>     Ngl.destroy(wks)
>
>
>
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/a4e2bad9/attachment.html>


More information about the pyngl-talk mailing list