AnsweredAssumed Answered

matplotlib.pyplot.show() crashes ArcGIS

Question asked by HEY_Candice on Jan 4, 2016
Latest reply on Jan 5, 2016 by jamesfreddyc

Hello everyone!


I'm creating a customizing tools in arcgis. I want to show some diagrams in arcgis, which made by matplotlib.

Everything works fine, the diagram kann even be saved in the right way, except when I show the plot through plt.show(), ArcGIS hangs and I have to force it to close with Task Manager.

Changing plt.show() to plt.show(block=False) should make the plot non-blocking, but this crashes ArcMap either, with a Runtime Error.

 

I am working with Windows 7 and ArcGIS 10.1.

 

The codes are something like:

 

import ConversionUtils

import arcpy

from arcpy import env

import matplotlib.pyplot as plt

 

xLabelName = ConversionUtils.gp.GetParameterAsText(0)

yLabelName = ConversionUtils.gp.GetParameterAsText(1)

Titel = ConversionUtils.gp.GetParameterAsText(2)

 

fig = plt.figure()
plt
.plot(range(10), range(10))

plt.xlabel(xLabelName, fontsize = 14)

plt.ylabel(yLabelName, fontsize = 14)

plt.title(str(Titel), fontsize = 16)

plt.grid()

plt.savefig('abc.png')

plt.show()

 

Because matplotlib uses TKinter by default, so the window pop up from plt.show() crashes ArcGIS.

The problem has been bothering me for days. I will greatly appreciate any ideas on how can I solve this Problem.

Thank you.

Outcomes