Change Legend Font Size and Fitting Strategy with ArcPy

02-08-2021 04:29 PM
Labels (1)
New Contributor III


I'm pretty new to ArcPy and am having with what is probably a fairly simple task. I'm trying to change the fitting strategy of a legend in a layout called "Test_Layout", and then change the font size of all elements in the legend to 8. Here is my code so far:


aprx ="CURRENT")
lyt = aprx.listLayouts("Test_Layout")[0]
leg = lyt.listElements("LEGEND_ELEMENT")[0]
leg.fittingStrategy = "AdjustFrame"
for elm in leg.items:
    fontSize = 8


Is anyone able to tell me what I'm doing wrong?

Thanks in advance!

0 Kudos
2 Replies
Esri Contributor

@DavidField ,

You can use element height and width to change the font size and legend size since LegendItem does not have fontSize property. 

leg.fittingStrategy = "AdjustColumnsAndFont"
print(leg.elementHeight, leg.elementWidth)
40.57 75.59

leg.elementHeight = 20
leg.elementWidth = 40

 This is the reference link for LegendElement::





Please give a like if helpful and Accept as Solution if it's answered your query.

New Contributor III

Apologies Mehdi,

I was pulled onto some other projects and have only just gotten back to this thread!

I tried the supplied code, however while I observed the fitting strategy set to "Adjust Columns and Font", and the legend size changes to 40w and 20h, neither the legend size changes, nor do any of the font sizes seem to change. Am I doing something wrong?


I am sure this has been uttered many times before on these forums, but does anyone know why on Earth ArcGIS Pro arcpy doesn't have a "fontSize" property?!?!

0 Kudos