First, we install matplotlib in the anaconda command window, using the pip command
pip install matplotlib
At this time we write a piece of code in Pythorm
import matplotlib
import matplotlib.pyplot as plt
print(matplotlib.__version__)
ax = plt.subplot(projection='3d') # 创建一个三维的绘图工程
run will report an error
TypeError: vars() argument must have __dict__ attribute
We first check the version of matplotlib in the python interpreter
You will find that what we just installed with pip is 3.7.0, but the one in pycharm is 3.6.2, so we need to install it again in pycharm
Double-click matplotlib to enter the following interface, click Install Pacekage
Wait for the installation to complete, run the imported matplotlib file in pycharm, and no error will be reported
Test code:
import numpy as np
import matplotlib.pyplot as plt
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C,S = np.cos(X), np.sin(X)
plt.plot(X,C)
plt.plot(X,S)
plt.show()