search

Home  >  Q&A  >  body text

matplotlib - problem with python function

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!

習慣沉默習慣沉默2730 days ago720

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-12 09:26:15

    Everything in python is an object

    It is equivalent to adding an attr to this object

    reply
    0
  • PHP中文网

    PHP中文网2017-06-12 09:26:15

    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.

    reply
    0
  • Cancelreply