1
votes

I installed Matplotlib via Anaconda from here: https://anaconda.org/conda-forge/matplotlib I used the very first command in Anaconda prompt.

But when I tried to plot from python (Spyder) as the following, I get the message: ModuleNotFoundError: No module named 'matplotlib.plot'

import numpy as np
import matplotlib.plot as plt

x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)

plt.plot(x,y)

I have installed numpy, pandas and such using the same method and they work well. How can I fix this?

Thank you so much.

1
The module is called pyplot. Hence you need import matplotlib.pyplot as plt.ImportanceOfBeingErnest
Wow, thank you so much. It worked...! Such silly mistake...James Lee

1 Answers

0
votes

matplotlib.pyplot is a state-based interface to matplotlib. pyplot is mainly intended for interactive plots and simple cases of programmatic plot generation. Therefore, whenever trying to work with graphs and what is commonly known and informally often referred as matplotlib you should import matplotlib.pyplot as plt:

import numpy as np
import matplotlib.pyplot as plt


x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)

plt.plot(x,y)