Select to view content in your preferred language

Format numbers in legend labels (Symbology classBreaks) in Python

480
0
03-02-2023 02:47 PM
Mahdi_Ch
New Contributor III

Hello All, 

In ArcGISPro in the Symbology pane under Advanced symbology options, there is a section that you can "Format numbers in legend labels", and I was looking for Python equivalent of that to reduce decimal points and set number format to percentage etc. 

I can access the labels and write some functions to handle them manually, but I was wondering if there is a Python method (maybe in CIM?) that can access the engine that gives this capability to ArcGISPro? 

Right now I would access labels like this: (Just part of the hypothetical script)

 

sym = lyr.symbology
cl_breaks= sym.renderer.classBreaks # list of break cutoff objects
# list of actual labels
labels_ls = [cl_breaks[i].label for i in range(len(cl_breaks))]
# the function that -hopefully I don't have to write- to get the labels and split and reformat them! 
formatted_labels = my_label_handler(labels_ls) 
for c, brk in enumerate(cl_breaks):
    brk.label = formatted_labels[c]
lyr.symbology = sym

 

 

Thank you! 

0 Kudos
0 Replies