I have been using the following code (works) to update the symbology of a layer in ArcGIS. Now, in addition to this, i need to change the thickness of the lines previously symbolized by using GraduatedColorsSymbology.
mxd = arcpy.mapping.MapDocument(mxdfile)
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Plot", df)[0]
lyr.visible = True
lyr.transparency = 0
sym = lyr.symbology
sym.valueField = "GrossTons"
sym.classBreakValues = [0, 1000000, 5000000, 10000000, 20000000, 40000000, 60000000, 600000000]
sym.classBreakLabels = ["<1M", "1M to 5M", "5M to 10M", "10M to 20M", "20M to 40M", "40M to 60M",">60M"]
arcpy.mapping.ExportToJPEG(mxd, "Export.jpg", "PAGE_LAYOUT", resolution=800)
del mxd
But when I try to add the color and thickness part, it gives an error saying 'GraduatedColorsSymbology' object has no attribute renderer.
Code added:
sym = lyr.symbology
sym.renderer.breakCount = 7
breakVal = 100000000000
cv = 0
lw = 1
for brk in sym.renderer.classBreaks:
brk.upperBound = breakVal
brk.label = "\u2264" + str(locale.format("%d", breakVal, grouping=True))
brk.description = "Description " + str(cv)
brk.symbol.color = {'HSV' : [cv, 100, 100, 100]}
brk.symbol.outlineColor = {'HSV' : [240-cv, 100, 100, 100]}
brk.symbol.size = lw
breakVal +=100000000000
cv += 40
lw += 0.5
lyr.symbology = sym
I didnt find any reference to this anywhere else. Is there a way to change the thickness and colors of lines in GraduatedColorsSymbology? Please avoid using
arcpy.ApplySymbologyFromLayer_management(lyr, symbologyLayer)
because this will not allow me to be flexible with changing class breakvalues.