Ipython Notebook: Default Initialization Python Code

China☆狼群 提交于 2019-12-05 18:25:27
shadanan

You can create Python files in $HOME/.ipython/profile_default/startup/ that contains the code you want executed at startup.

For example, you can create $HOME/.ipython/profile_default/startup/00-init.py:

# imports
from matplotlib import pyplot as plt
import matplotlib as mpl
from seaborn.apionly import set_palette
from IPython.display import set_matplotlib_formats

# configure plotting
set_matplotlib_formats('pdf', 'svg')
set_palette('Set1', n_colors=15, desat=None)
mpl.rcParams['figure.figsize']=(12.0,2.0)

Note that IPython magics are not supported here, so %matplotlib inline won't work. This question deals with making %matplotlib inline the default.

You should be aware that if you change the defaults for your IPython environment, your notebooks may not work on other people's IPython installations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!