代码如下
#encoding=utf-8 import numpy as np import matplotlib.pyplot as plt def main(): #line x=np.linspace(-np.pi,np.pi,156,endpoint=True) c,s=np.cos(x),np.sin(x) plt.figure(1) plt.plot(x,c) plt.plot(x,s) plt.show() if __name__=="__main__": main()
报错如下
Traceback (most recent call last):
File "D:/�����о����ĵ�/untitled/matplotlib Python��ͼ����/test/maplotlib test2.py", line 3, in <module>
import matplotlib.pyplot as plt
File "D:\anaconda\lib\site-packages\matplotlib\pyplot.py", line 71, in <module>
from matplotlib.backends import pylab_setup
File "D:\anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 16, in <module>
line for line in traceback.format_stack()
File "D:\anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 18, in <genexpr>
if not line.startswith(' File "<frozen importlib._bootstrap'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5 in position 11: ordinal not in range(128)
#encoding=utf-8 import numpy as np import matplotlib.pyplot as plt #line x=np.linspace(-np.pi,np.pi,256,endpoint=True) c,s=np.cos(x),np.sin(x) plt.figure(1) plt.plot(x,c) plt.plot(x,s) plt.show() 这样试一下