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!
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.