-5
fig = suptitle('image #{}'.format(num), fontsize=20)
NameError: name 'suptitle' is not defined

I already installed numpy, scipy and matplotlib and imported pylab but for some reason Python isn't recognizing the suptitle function.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
hunter
  • 21
  • 2
  • is `suptitle` a misspelling of `subtitle`? – Jonathan Hall May 21 '18 at 18:14
  • 1
    Well, did you define or import suptitle? Where? Show that part of the code. – Daniel Roseman May 21 '18 at 18:14
  • 'import pylab import imageio import suptitle myFilename = r'\Windows\video.mp4' vid = imageio.get_reader(myFilename, 'ffmpeg') nums = [10, 287] for num in nums: image = vid.get_data(num) fig = pylab.figure() fig = suptitle('image #{}'.format(num), fontsize=20) pylab.imshow(image) pylab.show()' – hunter May 21 '18 at 18:18
  • Python in general can only use functions that have been imported previously. It seems you want to use matplotlib pyplot's `suptitle` function here, so you may import it as `from matplotlib.pyplot import suptitle`. If you do so, the code you show will not produce any error. – ImportanceOfBeingErnest May 21 '18 at 18:31

1 Answers1

1

I think you need:

import matplotlib.pyplot as plt

plt.suptitle('image #{}'.format(num), fontsize = 20)
Scott Boston
  • 147,308
  • 15
  • 139
  • 187