HOW TO
Graduated colors symbology is used to show a quantitative difference between mapped features by varying the color of symbols. Data is classified into ranges that are each assigned a different color from a color scheme to represent the range. Refer to ArcGIS Pro: Graduated colors for more information.
It is possible to set a graduated colors renderer using the ArcPy module through the GraduatedColorsRenderer class.
The following steps describe how to set a graduated colors renderer using the ArcPy module:
import arcpy
p = arcpy.mp.ArcGISProject("CURRENT") m = p.listMaps("Map")[0] lyr = m.listLayers()[0] sym = lyr.symbology
sym.updateRenderer("GraduatedColorsRenderer") sym.renderer.colorRamp=p.listColorRamps("Cyan to Purple")[0]
classBreakValues = [25000,150000,1000000,3000000,10000000] classBreakLabels = ["div 1", "div 2", "div 3", "div 4", "div 5"]
sym.renderer.breakCount = len(classBreakValues) count = 0
for brk in sym.renderer.classBreaks: brk.upperBound = classBreakValues[count] brk.label = classBreakLabels[count] count += 1 lyr.symbology = sym
The following shows the full script:
import arcpy p = arcpy.mp.ArcGISProject("CURRENT") m = p.listMaps("Map")[0] lyr = m.listLayers()[0] sym = lyr.symbology sym.updateRenderer("GraduatedColorsRenderer") sym.renderer.colorRamp=p.listColorRamps("Cyan to Purple")[0] classBreakValues = [25000,150000,1000000,3000000,10000000] classBreakLabels = ["div 1", "div 2", "div 3", "div 4", "div 5"] sym.renderer.breakCount = len(classBreakValues) count = 0 for brk in sym.renderer.classBreaks: brk.upperBound = classBreakValues[count] brk.label = classBreakLabels[count] count += 1 lyr.symbology = sym
Get help from ArcGIS experts
Download the Esri Support App