UnclassedColorsRenderer

Zusammenfassung

The UnclassedColorsRenderer class draws quantities using an unclassed color gradient.

Auswertung

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.

Eigenschaften

EigenschaftErklärungDatentyp
colorRamp
(Lesen und schreiben)

Provides access to the ColorRamp object.

ColorRamp
expression
(Lesen und schreiben)

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
(Lesen und schreiben)

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
(Lesen und schreiben)

A string that represents the lower label that appears in the Contents pane or legend.

String
normalizationField
(Lesen und schreiben)

A string that represents a valid numerically defined field name that is used for normalization.

String
symbolTemplate
(Nur lesen)

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
(Nur lesen)

Returns a string that represents the renderer type.

String
upperLabel
(Lesen und schreiben)

A string that represents the upper label that appears in the Contents pane or legend.

String

Methodenübersicht

MethodeErklärung
updateSymbolTemplate (symbol_template)

updateSymbolTemplate provides a mechanism to change the renderer's symbol template.

Methoden

updateSymbolTemplate (symbol_template)
ParameterErklärungDatentyp
symbol_template

A reference to a symbol.

(Der Standardwert ist 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.

Codebeispiel

UnclassedColorsRenderer example

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