我试图通过调用执行绘图的函数在 ipython 笔记本中进行绘图,但出现错误。这是笔记本中的代码:
from mynamd.logutils import plot_energy_column
plot_energy_column('3x3x3/eq0.log', 4) # print dihedral
这是 plot_energy_column:
def plot_energy_column(logfile,column):
import matplotlib.pyplot as plt
plt.xlabel('time'); plt.ylabel(energy_keys[column])
plt.plot( fetch_energy_column(logfile,1), fetch_energy_column(logfile,column) )
plt.show()
这是错误:
NameError Traceback (most recent call last)
<ipython-input-97-8ef7f9adebf3> in <module>()
1 from mynamd.logutils import plot_energy_column,fetch_energy_column
----> 2 plot_energy_column('3x3x3/eq0.log', 4) # print dihedral
3 #show()
/home/jbq/code/python/mynamd/logutils.py in plot_energy_column(logfile, column)
28 plt.xlabel('time'); plt.ylabel(energy_keys[column])
29 plt.plot( fetch_energy_column(logfile,1), fetch_energy_column(logfile,column))
---> 30 plt.show()
31
32
NameError: global name 'show' is not defined
如果我plt.show()
从plot_energy_function
定义中删除并将 a 粘贴show()
在 ipython 笔记本的末尾,则会出现语义错误。任何澄清都非常感谢。
何塞