如何在pyplot中显示图形
我在运行这段代码时遇到了以下错误,我该怎么解决呢:
from numpy import *
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 15
fig = plt.figure ()
ax = fig.gca(projection='3d')
t = linspace (-2, 2, 100)
x = (1 + t**2) * sin(2 * pi * t)
y = (1 + t**2) * cos(2 * pi * t)
z = t
ax.plot(x, y, z, label='Parametric 3D curve')
ax.legend()
show()
错误信息:
追踪记录(最近的调用在最前面): 文件 "/home/me/workspace/mysecondpythontest/my1pythontest",第19行,在 show() 中出现了问题。NameError: 名称 'show' 未定义
1 个回答
3
这里说的是show()
这个东西不存在。
你需要使用plt.show()
这个命令。