[ncl-talk] Another ncl-python related question

Barry Lynn barry.h.lynn at gmail.com
Tue Mar 5 05:01:47 MST 2024


 Hello:


If someone has experience with using python for setting contours and label
bar (boxes with labels), I can't seem to drop the right most label bar box
-- it says no_label. I don't believe it should be plotted, as the contour
ends at 5.


min_val = -25.

 max_val = 5.

 space_val = 3.

 res.cnMinLevelValF = min_val

 res.cnMaxLevelValF = max_val

 res.cnLevelSpacingF = space_val

 res.cnLineThicknessF = 0. # Don't draw contour lines

 res.cnLinesOn = False

 res.lbLabelBarOn = True #-- draw a labelbar

#res.lbTitleString = "olr Reflectivity (dBZ)"

#res.lbTitleFontHeightF= .015

#res.lbTitleOffsetF =   -0.25 # plus is up

#res.lbTitleOffsetF =   -0.75 # plus is up

 res.lbLabelAlignment = "BoxCenters"

 res.lbLabelStrings = list(range(-25,5,3))

# Calculate the levels

 num_intervals = max_val - min_val

#levels = np.linspace(min_val * space_coef, (max_val+2) * space_coef,
num_intervals + 1)[1:-1]

#levels = np.linspace(min_val * space_coef, max_val * space_coef,
num_intervals)

 levels = np.linspace(min_val , max_val+space_val )


# Convert levels to string and assign to label bar

 string_levels = [str(level) for level in levels]  # Convert levels to
strings

 res.lbLabelStrings = string_levels

 print(res.lbLabelStrings)


-- 

Barry H. Lynn, Ph.D
Senior Scientist, Lecturer,
The Institute of Earth Sciences,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

Weather It Is, LTD
Weather and Climate Focus
https://weather-it-is.com <http://weather-it-is.com>
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240305/73642b72/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_ctt_contour_fill_on_map_py.pdf
Type: application/pdf
Size: 160407 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240305/73642b72/attachment.pdf>


More information about the ncl-talk mailing list