There is a class matplotlib.axes.AxesSubplot, but the module matplotlib.axes has no attribute AxesSubplot

后端 未结 2 843
长情又很酷
长情又很酷 2020-12-09 08:52

The code

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
print type(ax)

gives the output



        
2条回答
  •  既然无缘
    2020-12-09 09:43

    Another way to see what DSM said:

    In [1]: from matplotlib import pyplot as plt                                                                                                                                                                       
    
    In [2]: type(plt.gca()).__mro__                                                                                                                                                                                    
    Out[2]: 
    (matplotlib.axes._subplots.AxesSubplot,
     matplotlib.axes._subplots.SubplotBase,
     matplotlib.axes._axes.Axes,
     matplotlib.axes._base._AxesBase,
     matplotlib.artist.Artist,
     object)
    

    with the dunder method resolution order you can find all the inheritances of some class.

提交回复
热议问题