I am trying to use python to adjust my graduated color symbols' class breaks and labels. The layer is a query layer tied to an SQL DB and I want to be able to execute my python (after the database has been updated) to automatically author a map and have the layer/legend reflect the changes made in the database. I've tried this script but it doesn't work and I get an error I don't recognize.
import arcpy mxd = arcpy.mapping.MapDocument("current") df = arcpy.mapping.ListDataFrames(mxd, "Layers") lyr = arcpy.mapping.ListLayers(mxd, "Unsafe_Driving", df) if lyr.symbologyType == "GRADUATED_COLORS": lyr.symbology.valueField = "CSA.DBO.%Unsafe_Driving_1.VARIANCE" lyr.symbology.classBreakValues = [-.01, .01, .0866] lyr.symbology.classBreakLabels = ["-8.66% to -1.00%", "-.99% to 1.00%","1.01% to 8.66%"] arcpy.RefreshActiveView()
Runtime error Traceback (most recent call last): File "", line 7, in File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects_base.py", line 87, in _set return setattr(self._arc_object, attr_name, cval(val)) RuntimeError
The goal here is to have 3 classes:
- Lowest value to -1.00%
- -.99% to 1.00%
- 1.01% to the highest value.
Since the lowest and highest values can change, do I need to use a query to dynamically insert those into the lyr.symbology.classBreakValues?