An extra label box when using python

18 Views Asked by At

I am not able to get python to plot a map without adding in the label bar an extra sub-box (interval), which is not labeled correctly (just label_XX). Also, the last box labeled is by interval 1 instead of 2. ChatGPT could not solve the problem, for me.

min_val = -15
max_val = 8. # Make sure this is an even number, or you'll get "no_label!"
space_val = 2.
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.lbLabelAlignment = "BoxCenters"
res.lbLabelStrings = list(range(int(min_val),int(max_val)+2*int(space_val),int(space_val)))  
print(res.lbLabelStrings)
res.lbOrientation = "horizontal"
res.pmLabelBarOrthogonalPosF = -0.08 #-- move labelbar upward
res.lbLabelFontHeightF = 0.009
res.lbBoxMinorExtentF = 0.17
res.lbBoxMajorExtentF = 0.75
Skip non relevant code
plot_rad = Ngl.contour(wks, cloud_top_temp, res)
plot_topo = Ngl.contour(wks, hgt, topo_res)
Ngl.overlay(map,plot_topo)

I was expecting for there to be one less label box in the label "bar." I've tried numerous iterations from ChatGTP, but none of them worked. I need to be able to explicitly tell python how many sub-boxes with the bar to shoow.

0

There are 0 best solutions below