打开 ~/.ipython/profile_default/ipython_config.py
, 输入一下内容
import matplotlib as mpl
c = get_config()
# 多个输出打印
# c.InteractiveShell.ast_node_interactivity = "all"
# 加载插件
c.InteractiveShellApp.extensions = ['autoreload']
# 默认引入的库
c.InteractiveShellApp.exec_lines = [
"import pandas as pd", # 载入pandas
"import numpy as np", # 载入numpy
"import matplotlib.pyplot as plt", # 载入绘图库
"import seaborn as sns", # 图表更美观
"import ipywidgets as widgets", # 记载交互性控件
"%load_ext memory_profiler", # 加载内存分析模块
"%load_ext line_profiler", # 加载行分析模块
"%load_ext Cython", # 支持直接编译cpython
'%autoreload 2'
]
# 默认绘图库直接显示
c.IPKernelApp.matplotlib = 'inline'
# 设置绘图库的字体。支持中文
mpl.rcParams['font.sans-serif'] = ['SimHei']
# 显示负号
mpl.rcParams['axes.unicode_minus'] = False
# matplotlib在Retina屏幕中显示模糊问题
c.InlineBackend.figure_format = 'retina'
打开 ~/.jupyter/custom/custom.css
pre.CodeMirror-line {
font-family: 'BlinkMacSystemFont', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif
}
.output_subarea.output_text.output_result>pre {
font-family: 'BlinkMacSystemFont', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif
}
.output_subarea.output_text.output_stream.output_stdout>pre {
font-family: 'BlinkMacSystemFont', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif
}
#notebook-container {
max-width: 830px;
padding: 40px;
}
同样的。我们可以下载 jupyterthemes 来达到一样的效果.
https://github.com/mmmwhy/jupyter-themes
下载ttf字体文件到 /opt/anaconda3/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf
下
删除cache. rm -rf ~/.matplotlib/*.cache
如果出现 RuntimeError: Python is not installed as a framework. 错误。可以执行一下命令.
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
下载插件管理器. jupyter notebook extensions
https://github.com/ipython-contrib/jupyter_contrib_nbextensions
下载 jupyter dashboard. 用于将输出组成合适的文档交付
select codemirror keymap 修改代码风格为vim