Making Graphs with Python

2909
2
07-22-2012 12:41 PM
NickJones
New Contributor II
I've made some changes to the python script below and I keep getting an error that says:

Executing: Script
Start Time: Sun Jul 22 16:28:51 2012
Running script Script...
<type 'exceptions.SyntaxError'>: invalid syntax (GraphTemp.py, line 2)
Failed to execute (Script).
Failed at Sun Jul 22 16:28:51 2012 (Elapsed Time: 0.00 seconds)

This is the first time I've tried to use Python. So, sorry if this is really basic.

import arcpy

# Set local variables:
output_graph_name = "VerticalLineGraph"
verticalLineGraph_bmp = "C:/temp/VerticalLineGraph.bmp"
inputTemplate = "C:\GIS\GwinnettStormDrainage\ConduitModel\GraphOfConduitVertexPoints.grf"
inputData = "C:\GIS\GwinnettStormDrainage\TestData\PointFiles\2304296.shp"

# Create the graph
graph = arcpy.Graph()

# Add vertical line series to the graph

addSeriesLineVertical (inputData, "Invert", "Distance", Asc)
addSeriesLineVertical (inputData, "Crown", "Distance", Asc)
addSeriesLineVertical (inputData, "GrElev", "Distance", Asc)


# Specify the title of the left axis
graph.graphAxis[0] = "Elevation"

# Specify the title of the bottom axis
graph.graphAxis[2] = "Distance"

# Specify the title of the Graph
graph.graphPropsGeneral.title = "Facility ID"

# Output a graph, which is created in-memory
arcpy.MakeGraph_management(inputTemplate, graph, output_graph_name)

# Save the graph as an image
arcpy.SaveGraph_management(output_graph_name, verticalBarGraph_bmp, "MAINTAIN_ASPECT_RATIO", "600", "375")

Thanks,

Nick Jones
Tags (2)
0 Kudos
2 Replies
DarrenWiens2
MVP Honored Contributor
Try it using proper path syntax (ie. no backslashes, unless you put "r" in front, or escape with a second backslash.
1) "C:/Path/path"
2) "C:\\path\\path"
3) r"C:\path\path"
0 Kudos
NickJones
New Contributor II
I changed all of the slashes, and I still got the error.  I got the script from here:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Graph/000v0000013w000000/

Thanks,

Nick Jones
0 Kudos