matplotlib - problem with python function
習慣沉默
習慣沉默 2017-06-12 09:24:15
0
2
718
def createPlot():
    fig = plt.figure(1, facecolor = 'white')
    fig.clf()
    createPlot.ax1 = plt.subplot(111, frameon = False)
    plotNode('nonLeafNode', (0.2, 0.1), (0.4, 0.8), nonLeafNodes)
    plotNode('LeafNode', (0.8, 0.1), (0.6, 0.8), leafNodes)
    plt.show()

createPlot()

What does createPlot.ax1 in the code mean? I’ve never seen it used like this before, so I’m asking for advice!

習慣沉默
習慣沉默

reply all(2)
phpcn_u1582

Everything in python is an object

It is equivalent to adding an attr to this object

洪涛

It’s okay as mentioned above, but why isn’t it helpful? createPlot in python is a function and an object at the same time. Objects in python implement similar dictionary types. There is no problem in dynamically adding an attribute to the object.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template