Select to view content in your preferred language

arcpy.CreateGraph_management - display?

4508
11
08-01-2014 01:03 PM
JayLaura
Deactivated User

Via a Python toolbox I am calling arcpy.CreateGraph_management('default.tee', graphobj, 'temp'), where graphobj is a graph object created using the arcpy.Graph() class.

When I execute my tool, the create graph call is made without error, but a graph is never displayed.  Additionally, the graph does not appear in the Graph Manager.  Oddly, when I start to type the CreateGraph command into the command prompt, I see that 'temp' is available as a '.grf' file to fulfill the first argument.

The CreateGraph documentation suggests that the graph needs to be added to the 'host application', but does not provide any guidance.  How can a PythonToolbox create a graph and then display it?

Tags (2)
11 Replies
JasonScheirer
Esri Alum

Do you have background geoprocessing turned on?

0 Kudos
JayLaura
Deactivated User

No.  I have it turned off (deselected in Geoprocessing Options).

I should add: ArcGIS 10.2.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Interesting...in ArcMap 10.2.2 there is no arcpy.CreateGraph_management but there is an arcpy.MakeGraph_management

0 Kudos
JayLaura
Deactivated User

I am calling MakeGraph - apologies.

arcpy.MakeGraph_management(graph_grf, graph, outgraphname)

0 Kudos
DanPatterson_Retired
MVP Emeritus

Help topic 

  • The output graph is an in-memory graph that can be added to the host ArcGIS application or can be saved using the Save Graph tool.
  • Make Graph can be used on a Windows platform only.

I don't know if you have to add it manually or do you have the default Arcmap setting of Add Results to Display checked on, or whether you have to go to Save Graph...You are in a better position to experiment

addendum see this help topic as well

JayLaura
Deactivated User

Dan,

Thanks for the info.  Those are the docs. that I have been referencing.  No guidance exists (as far as I can tell) for adding to the host ArcGIS application.  The graph does not appear to be a layer - so addable in the same way a layer is.

Saving puts the file on disk (not in grf format).  If I am forced to go the latter route, I would just use MatPlotLib as I get a lot more control over the final figure.  My preference would be to use the former, but experimentation so far has not gotten the figure to display.

In an interactive session, in ArcMap, the graph displays without issue.

Thanks,

Jay

0 Kudos
DanPatterson_Retired
MVP Emeritus

ArcMap has to be open and you require an existing graph or a template.  So your last line pretty well sums up the expected behaviour

0 Kudos
FilipKrál
Frequent Contributor

Yeah, I think ArcMap is "the host application" that the graph will be added to, as Dan pointed out.

Laura, you mentioned you would use matplotlib to make your plots. I always find that with matplotlib you need to write quite a bit of code to make even fairly basic plot. Have you got any predefined functions or hints that make plotting easier? We have some in arcapi library, but there is a space for enhancements.

Filip.

0 Kudos
JayLaura
Deactivated User

Filip,

I do not have additional helper functionality for MatPlotLib.  Using pyplot or pylab, I have not needed to abstract out much of my work.  In conjunction with Pandas, I am pretty well set.

What I would love to see is a more robust library for conversion from MatPlotLib to D3.  At this point, the most robust method I have found is to pipe JSON to D3.  It would be amazing to have some D3 plotting functionality inline in ArcMap, a la a iPython notebook.

Thanks,

Jay

0 Kudos