Reputation: 1879
I am working with a legacy codebase that uses python modules together with jupyter notebook. The plotting functionality is contained in the python modules eg:
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()
I would rather not add ply.show() to all the places in the legacy code where pyplot is used.
Is there a global way to 'force' pyplot to show when get_ipython() is not in the global context?
Upvotes: 1
Views: 455
Reputation: 6891
If you work in interactive mode, plot is shown directly. You turn on interactive mode by calling plt.ion()
once. Thus you still have to modify your legacy code, by adding this command, but that needs only to be done once, in the beginning of the program.
Upvotes: 1