How can I round to 2 decimal places the feature class legend label in arcgis pro with python code, if it is divided into 5 classes using natural break method? The value is rounded up with my code, but still 6 decimal places are displayed. How to do it from code, because it would be part of a pdf printer process and it would be very important that the symbol explanation is easy to read. I can only do this by manual adjustment (Advanced symbolgy options/Rounding).
original label: 0.234567 - 0.41277
rounded by script: 0.230000 - 0.410000
I would like this: 0.23 - 0.41
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.listMaps('MAP')[0]
l = m.listLayers("NDVI_mean")[0]
sym = l.symbology
if sym.renderer.type == "GraduatedColorsRenderer":
if sym.renderer.classificationMethod == "NaturalBreaks":
breaks = sym.renderer.classBreaks
for tor in breaks:
rounded_break_values = round(float(tor.upperBound), 2)
tor.upperBound = rounded_break_values
l.symbology = sym