我使用stem_graphic
绘制了一个茎叶图,并将其保存为Figure object have no attribute set_title
格式,但在尝试输入标题时出现错误: pdf。
ax, b=stem_graphic(mileage['disp'])
ax.set_title("Vicky")
This is the error
Traceback (most recent call last):
File "<pyshell#214>", line 1, in <module>
ax.set_title("Vicky")
AttributeError: 'Figure' object has no attribute 'set_title'
发布于 2017-06-28 20:10:44
看起来您的stem_graphic
函数返回了一个matplotlib.figure
对象,因此您应该使用suptitle()
方法来添加标题。
尝试:
fig, b = stem_graphic(mileage['disp'])
fig.suptitle("Vicky")
发布于 2017-06-28 20:21:51
词干图包中的stem_graphic
函数返回一个图形和一个轴;docstring表示
:返回: matplotlib图形和轴实例
因此,代码应该如下所示
fig, ax =stem_graphic(mileage['disp'])
ax.set_title("Vicky")
https://stackoverflow.com/questions/44811302
复制相似问题