njones623

Making Graphs with Python

Discussion created by njones623 on Jul 22, 2012
Latest reply on Jul 22, 2012 by njones623
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

Outcomes