to reverse classes order sybmology graduated colors

12-05-2019 08:08 AM
New Contributor III

Does anyone have some sample code using that will reverse the values for the classes order using a graduatedcolorrender?

What I am trying to do is automate this step using in ArcGIS pro the functionality or step is in the symbology window using graduated colors, natural breaks (method) in the classes tab there is a more pull down where you can reverse values.



2 Replies
MVP Esteemed Contributor

This level of granularity/detail requires .NET programming, is higher level - it doesn't have every bit of functionality like the pulldown you mention implemented as a method applicable to the layer object.

However, you can set up a symbology interactively, save to a lyrx file and use to apply the .lyrx symbology to a layer.

MVP Regular Contributor

Just curious whether there were any updates to that allow you to reverse the color ramp?

Funny thing is, I can set, for example, Yellow to Red but not Red to Yellow.


This works:


sym.renderer.colorRamp = p.listColorRamps('Yellow to Red')[0]



This produces an error:


sym.renderer.colorRamp = p.listColorRamps('Red to Yellow')[0]
IndexError                                Traceback (most recent call last)
In  [40]:
Line 15:    sym.renderer.colorRamp = p.listColorRamps('Red to Yellow')[0]

IndexError: list index out of range



0 Kudos