我尝试通过调用一个执行绘图的函数在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
并在ipython笔记本末尾添加show()
,则会出现seme错误。任何澄清都是T-welcome。
何