Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

python add-in and matplotlib crash

$
0
0
I'm trying to make a python add-in toolbar that displays a graph. I can create a graph with a function in command line without any difficulty, but when I try to create the same graph from within a class for the add-in, it crashes. The crash happens whether the class is made in the command line or the add-in button. What happens is the graph appears, then a few seconds later, arcmap unexpectedly shuts down, and asks if I want to send an error report.

The class causing the crash is:
Code:

class ButtonClass15(object):
    """Implementation for WizardTest_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        allVals = ((1,1),(2,2),(3,3))
        valArray = np.array (allVals)
       
        rasterArray  = valArray [:,0]
        distanceArray = valArray [:,1]

        pyplot.plot(distanceArray, rasterArray, 'r' )
        pyplot.xlabel('Distance from Start')
        pyplot.ylabel('Raster Val')
        pyplot.show()


Does anyone have any workarounds that would let me display the graph while still creating it with an add-in button?

Thanks!

Viewing all articles
Browse latest Browse all 2485

Trending Articles