ColorRamp provides access to a color ramp that is available in a project.


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.


The list of available color ramps is dependent on the styles that are loaded into a project. The best way to view the list is to open the Catalog view and then expand the Styles folder in the Contents pane. If you select the default installed ArcGIS Colors style, you will see that it contains more than 100 color schemes.


PropiedadExplicaciónTipo de datos
(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.


Muestra de código

ColorRamp example

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 = + 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')