8

I have used stem_graphic to plot a stem and leaf plot and saved it to pdf but when trying to enter title its giving error: Figure object have no attribute set_title.

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'
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
Vicky Choudhary
  • 81
  • 1
  • 1
  • 2

2 Answers2

7

It looks like your stem_graphic function returns a matplotlib.figure object, so you should use the suptitle() method to add a title.

try:

fig, b = stem_graphic(mileage['disp'])
fig.suptitle("Vicky")
aorr
  • 937
  • 7
  • 9
0

The stem_graphic function from the stemgraphic package returns a figure and an axes; the docstring states

:return: matplotlib figure and axes instance

The code should therefore look like

fig, ax =stem_graphic(mileage['disp'])
ax.set_title("Vicky")
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712