【发布时间】:2018-03-10 21:47:53
【问题描述】:
我正在使用一个遗留代码库,该代码库将 python 模块与 jupyter notebook 一起使用。绘图功能包含在 python 模块中,例如:
from matplotlib import pyplot as plt
class SomeClass(object):
def plot(self, x_data, y_data)
plt.plot(x_data, y_data)
#I added this code to show plot if not using notebook
plt.show()
我宁愿不将 ply.show() 添加到遗留代码中使用 pyplot 的所有位置。
是否有一种全局方法可以“强制”pyplot 显示 get_ipython() 何时不在全局上下文中?
【问题讨论】:
-
您可以将其保存为图像并使用
os.system("open filename.png")打开它 -
这个不清楚。除了您指定
plt.show()之外,程序如何知道在什么时候显示其他内容?
标签: python matplotlib jupyter-notebook