UnclassedColorsRenderer

Synthèse

The UnclassedColorsRenderer class draws quantities using an unclassed color gradient.

Discussion

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.

Propriétés

PropriétéExplicationType de données
colorRamp
(Lecture et écriture)

Provides access to the ColorRamp object.

ColorRamp
expression
(Lecture et écriture)

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
(Lecture et écriture)

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
(Lecture et écriture)

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

String
normalizationField
(Lecture et écriture)

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

String
symbolTemplate
(Lecture seule)

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
(Lecture seule)

Returns a string that represents the renderer type.

String
upperLabel
(Lecture et écriture)

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

String

Vue d’ensemble des méthodes

MéthodeExplication
updateSymbolTemplate (symbol_template)

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

Méthodes

updateSymbolTemplate (symbol_template)
ParamètreExplicationType de données
symbol_template

A reference to a symbol.

(La valeur par défaut est 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.

Exemple de code

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