Why isn't subplots in matplotlib working?

Question:

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?

Asked By: MarJer

||

Answers:

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.

Answered By: Cameron Riddell
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.