Resumen
ColorRamp provides access to a color ramp that is available in a project.
Debate
To reference a color ramp in a project, use the listColorRamps method on the ArcGISProject class. Once a color ramp is referenced, you can assign it to the colorRamp property that is available to the GraduatedColorsRenderer, GraduatedSymbolsRenderer, RasterStretchColorizer, UnclassedColorsRenderer, and UniqueValueRenderer classes.
Propiedades
Propiedad | Explicación | Tipo de datos |
name (Sólo lectura) | Gets the name associated with the color ramp. A valid value is only available if a color ramp is referenced using the listColorRamps method on the ArcGISProject object. If a ColorRamp is returned from a renderer or colorizer, the name property will return an empty string because the name is not persisted with the renderer or colorizer. | String |
Muestra de código
The following script changes the colorRamp property of a GraduatedColorsRenderer to a color ramp named Cyan to Purple that is available in the project.
import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + r"\\GraduatedColors.aprx")
m = p.listMaps("Layers")[0]
l = m.listLayers("Natural*")[0]
sym = l.symbology
colorRamp = p.listColorRamps("Cyan to Purple")[0]
sym.renderer.colorRamp = colorRamp
l.symbology = sym
p.saveACopy(relpath + r'\\SavedOutput.aprx')