The behavior of classBreaks.upperBound changes

132
2
2 weeks ago
-_-
by
New Contributor III

I'm trying to set the minimum and maximum values for a graduated color layer with a script tool. (This is a slightly more complicated piece of code)
Below is the code.

 

glyr=arcpy.GetParameterAsText(0)

glyrlist=glyr.split("\\")
glp=glyrlist[0]
lyr=glyrlist[-1]

aprx=arcpy.mp.ArcGISProject("CURRENT")
activelayout=aprx.activeView
mpflames=activelayout.listElements("MAPFRAME_ELEMENT")[0]
maps=mpflames.map

lays=maps.listLayers(lyr)
for ly in lays:
    if "\\" in ly.longName:
        if ly.longName.split("\\")[0]==glp:
            l=ly
    else:
        l=ly

sym=l.symbology
if hasattr(sym,'renderer'):
    if sym.renderer.type=="GraduatedColorsRenderer" or sym.renderer.type == "GraduatedSymbolsRenderer":
#min
        l_cim=l.getDefinition('V3')
        l_cim.renderer.minimumBreak=-100000000
        l.setDefinition(l_cim)
#max
        sym=l.symbology
        sym.renderer.classBreaks[-1].upperBound=100000000
        l.symbology=sym

 

This code works as desired when you set up a layer with three or more classes.
However, when the number of classes is 2, the behavior becomes strange as shown in the figure. Also, at this time, if you change "100000000" on line 29 to "1000000", it will work properly.

タイトルなし3.pngタイトルなし4.png

Why does this happen?

The image below shows a slightly more complex code.
The color of the "3" square has changed.

タイトルなし.pngタイトルなし2.png

I don't know the cause of this either.

Is there any way to solve it? thank you.

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

perhaps you understand this comment

If you change upperBound of a ClassBreak, the classificationMethod automatically changes to ManualInterval. You also need to manually update the labels and/or descriptions accordingly.

in

GraduatedColorsRenderer—ArcGIS Pro | Documentation

code example 2 gives an example


... sort of retired...
0 Kudos
-_-
by
New Contributor III

Sorry, I didn't quite understand what you meant.
The problem I'm having is that although the upper limit value is set properly as far as I can see in the class tab, the colors don't match it.

0 Kudos