How to Solve NameError: name 'gridspec' is not defined -- matplotlib

Solution: Import the 'gridspec' module

To Solve the error, add the following line to the top of your code.

from matplotlib import gridspec

 

For more information:
Python matplotlib gridspec