在ipython笔记本中绘图时,未定义全局名称“show”

时间:2013-08-25 15:06:58

标签: matplotlib ipython-notebook

我尝试通过调用一个执行绘图的函数在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。

0 个答案:

没有答案