I am aware of accessing color ramp using the ColorRamp method of the arcpy.mp module. However, this only gets existing color ramps.
Is there any way of creating new color ramp programmatically, for example, Yellow to Black?
1 Answer 1
Better later than never. If your desired color scheme is not available, you can create one manually, save it, and then call it in your script. For example, here's what I did to get a Red to Yellow scheme (which didn't exist) in a graduated colors ramp using ArcGIS Pro 2.8.0:
1.) Symbology pane --> Color Scheme drop down --> Format color scheme...
2.) In the Color Sceme Editor, match the color stops with the amount of class breaks and give them the relevant color(s).
3.) Save to a style... --> Name it and hit OK. It will be saved with the other ramps.
Now you can call it in your script:
import arcpy
aprx = arcpy.mp.ArcGISProject('CURRENT')
colorramps = aprx.listColorRamps()
for color in colorramps:
print(color.name)
Red To Yellow
Accent (3 Classes)
Accent (4 Classes)
Accent (5 Classes)
Accent (6 Classes)
Accent (7 Classes)
Accent (8 Classes)
Aspect
Basic Random
Bathymetric Scale
Bathymetry #1
Bathymetry #2
Bathymetry #3
Bathymetry #4
Bathymetry #5
Black and White
Black to White
Blue-Brown-Red 2x2
Blue-Brown-Red 3x3
...
Explore related questions
See similar questions with these tags.
The fill color graduates from red to blue, and the outline color goes from blue to red and increases in size with each break.
. So you can create your own, you just need to figure out the colors.