Resumen
The UnclassedColorsRenderer class draws quantities using an unclassed color gradient.
Debate
The properties behave in a similar manner to the options exposed in the application. For example, changing the field will automatically adjust the upper and lower labels. If you change expression, the field automatically changes to Custom.
Propiedades
Propiedad | Explicación | Tipo de datos |
colorRamp (Lectura y escritura) | Provides access to the ColorRamp object. | ColorRamp |
expression (Lectura y escritura) | A string that represents a valid SQL expression. When an expression is applied, the field name in the Symbology pane appears as Custom. | String |
field (Lectura y escritura) | A string that represents a valid, numerically defined field name used for setting unclassed colors. A value of None is possible, but it must be changed to a valid field name for the renderer to display properly. | String |
lowerLabel (Lectura y escritura) | A string that represents the lower label that appears in the Contents pane or legend. | String |
normalizationField (Lectura y escritura) | A string that represents a valid numerically defined field name that is used for normalization. | String |
symbolTemplate (Sólo lectura) | Returns a symbol that represents the symbol template for all the features in the layer. To set the template, use the updateSymbolTemplate method. | Symbol |
type (Sólo lectura) | Returns a string that represents the renderer type. | String |
upperLabel (Lectura y escritura) | A string that represents the upper label that appears in the Contents pane or legend. | String |
Descripción general del método
Método | Explicación |
updateSymbolTemplate (symbol_template) | updateSymbolTemplate provides a mechanism to change the renderer's symbol template. |
Métodos
updateSymbolTemplate (symbol_template)
Parámetro | Explicación | Tipo de datos |
symbol_template | A reference to a symbol. (El valor predeterminado es None) | Object |
The updateSymbolTemplate method allows you to modify the symbol for all the features at once. The symbol template is managed in the application differently and therefore requires a method to set the symbol template to the renderer.
Muestra de código
The following script first tests whether the layer's symbology supports a renderer property. It then confirms whether the renderer type is an UnclassedColorsRenderer. Next, it modifies basic properties such as fields and labels. Next, it applies a system ColorRamp named Yellow to Red. Finally, it modifies the symbolTemplate using a gallery symbol named Black Outline (1pt).
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('UnclassedColors')[0]
l = m.listLayers('States_WithRegions')[0]
if l.isFeatureLayer:
sym = l.symbology
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'UnclassedColorsRenderer':
#modify basic properties
sym.renderer.field = "POP2010"
sym.renderer.normalizationField = "Shape_Area"
sym.renderer.lowerLabel = "Upper: " + sym.renderer.lowerLabel
sym.renderer.upperLabel = "Lower: " + sym.renderer.upperLabel
#Modify color ramp
cr = p.listColorRamps('Yellow to Red')[0]
sym.renderer.colorRamp = cr
#Modify the symbol template
symTemp = sym.renderer.symbolTemplate
symTemp.applySymbolFromGallery('Black Outline (1pt)')
sym.renderer.updateSymbolTemplate(symTemp)
l.symbology = sym