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

Solution: Import the 'ListedColormap' module

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

from matplotlib.colors import ListedColormap

 

For more information:
Python matplotlib ListedColormap