Changing layer symbology

Discussion created by d484648 on Aug 6, 2013
Latest reply on Oct 16, 2013 by simontp
I???m trying to change the class break values for a layer that has graduated colors symbology.  The layer has three data ranges and the classification method is natural breaks.

Here is the code I???m trying to run:

import arcpy
from arcpy import env
mapdoc = arcpy.mapping.MapDocument(r"C:\data\Population.mxd")
df = arcpy.mapping.ListDataFrames(mapdoc, "layers")[0]
lyr = arcpy.mapping.ListLayers(mapdoc, "Population", df)[0]
lyrFile = arcpy.mapping.Layer(r"C:\data\update_layer.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrFile, True)
lyr.symbology.classBreakValues = [1, 100, 250, 550]

When I run the script line-by-line in ArcMap???s Python window everything seems to work, up to and including the UpdateLayer line; the colors and data breaks change correctly and the layer still has natural breaks.  But running the last line gives me the following error:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 87, in _set
    return setattr(self._arc_object, attr_name, cval(val))

At that point when I go to the symbology tab of the layer???s properties, there are three ranges but they are listed as 0-100, 0-250 and 0-550 and they have no symbols associated with them.

When I start all over again and re-run everything and update the layer but instead try to change the number of classes with the line

lyr.symbology.numClasses = 4

I get the same error message as above.  When I try to access the layer???s properties a warning in ArcMap pops up:  ???Encountered an improper argument.???  If I click OK on the warning it lets me into the symbology tab but the dialog areas for all of the options under Quantities (Graduated colors, graduated symbols, etc) have the heading ???NO DESCRIPTION" and are otherwise blank.

This seems like a pretty straightforward script.  I can't figure out where the problem is.  I'm hoping someone can help me figure this out.