Why isn't subplots in matplotlib working?

I have a python-script that is meant to test the functionality of matplotlib (among others). The script is working in terminal and Python console, but not in saved files executed from PyCharm (Linux) or Visual Studio Code (Windows). I do get the same error message for both environments about subplots missing, se screen dump:
enter image description here

The matplotlib code is copied from matplotlibs website for example code. What am I missing?

>Solution :

There is a small difference between your code and the example code:

import matplotlib.pyplot as plt # import in the example
import matplotlib as plt # your code

Just need to fix your import.

Leave a Reply