from matplotlib.pylab import *
will take care of all of your imports, but some of the interactive stuff (show
etc) might not work correctly.
문제
In an Ipython notebook, I have defined a function to plot data. I would like to import the function in my current notebook to use it. I tried to convert the mynotebook.ipynb to a mynotebook.py file and then just do
from mynotebook import myfunction
But I get an error. The problem is that I wrote the original notebook with starting ipython with the option pylab. That means that to make it work, instead of writing something like
x = arange(1,10)
y = arange(1,10)
scatter(x, y)
I should change it to the more explicit:
import numpy as np
import matplotlib as plt
x = np.arange(1,10)
y = np.arange(1,10)
plt.scatter(x, y)
In my case my file is quite complex and changing it will be a pain... Is there a way to import my notebook without modifying the .py file line by line???
해결책
from matplotlib.pylab import *
will take care of all of your imports, but some of the interactive stuff (show
etc) might not work correctly.