我想在浏览器中增加ipython笔记本的宽度。我有一个高分辨率的屏幕,我想扩大单元格的宽度/大小,以利用这个额外的空间。
谢谢!
编辑/回答:2017年5月
我现在使用jupyterthemes: https://github.com/dunovank/jupyter-themes
还有这命令:
jt -t oceans16 -f roboto -fs 12 -cellw 100%
这设置宽度为100%与一个漂亮的主题。
我想在浏览器中增加ipython笔记本的宽度。我有一个高分辨率的屏幕,我想扩大单元格的宽度/大小,以利用这个额外的空间。
谢谢!
编辑/回答:2017年5月
我现在使用jupyterthemes: https://github.com/dunovank/jupyter-themes
还有这命令:
jt -t oceans16 -f roboto -fs 12 -cellw 100%
这设置宽度为100%与一个漂亮的主题。
当前回答
为了让它与jupyter(版本4.0.6)一起工作,我创建了~/.jupyter/custom/custom.css,其中包含:
/* Make the notebook cells take almost all available width */
.container {
width: 99% !important;
}
/* Prevent the edit cell highlight box from getting clipped;
* important so that it also works when cell is in edit mode*/
div.cell.selected {
border-left-width: 1px !important;
}
其他回答
这是我最终使用的代码。它将输入和输出单元格向左和向右拉伸。注意,输入/输出数字指示将消失:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
display(HTML("<style>.output_result { max-width:100% !important; }</style>"))
display(HTML("<style>.prompt { display:none !important; }</style>"))
对于Firefox/Chrome用户,实现100%宽度的好方法是使用自定义TamperMonkey脚本。
好处是
在浏览器中配置一次,不需要修改服务器配置。 工作与多个jupyter服务器。 TamperMonkey是可信的、维护的、稳定的。 很多额外的定制是可以通过javascript实现的。
这个脚本为我工作https://gist.githubusercontent.com/mrk-andreev/2a9c2538fad0b687c27e192d5948834f/raw/6aa1148573dc20a22fca126e56e3b03f4abf281b/jpn_tmonkey.js
为了让它与jupyter(版本4.0.6)一起工作,我创建了~/.jupyter/custom/custom.css,其中包含:
/* Make the notebook cells take almost all available width */
.container {
width: 99% !important;
}
/* Prevent the edit cell highlight box from getting clipped;
* important so that it also works when cell is in edit mode*/
div.cell.selected {
border-left-width: 1px !important;
}
对于Chrome用户,我推荐Stylebot,它可以让你覆盖任何页面上的任何CSS,也可以让你搜索和安装其他共享自定义CSS。然而,出于我们的目的,我们不需要任何提前的主题。打开Stylebot,更改为编辑CSS。Jupyter捕获了一些击键,因此您将无法键入下面的代码。只需复制粘贴,或只需你的编辑器:
#notebook-container.container {
width: 90%;
}
改变宽度随你喜欢,我发现90%看起来比100%更好。但这完全取决于你的眼睛。
我通常在新安装后修改存储所有视觉样式的主css文件。我使用Miniconda,但位置与其他C:\Miniconda3\Lib\site-packages\notebook\static\style\style.min.css类似
对于某些屏幕,这些分辨率是不同的,并且大于1。为了安全起见,我把所有屏幕都改成了98%,所以如果我断开了笔记本电脑的外部屏幕,我的屏幕宽度仍然是98%。
然后用98%的屏幕宽度替换1140px。
@media (min-width: 1200px) {
.container {
width: 1140px;
}
}
后编辑
@media (min-width: 1200px) {
.container {
width: 98%;
}
}
保存并重新启动你的笔记本
更新
最近不得不拓宽Jupyter细胞上的一个环境,它是安装,这导致我回到这里,提醒自己。
如果你需要在虚拟环境中安装jupyter。你可以在这个子目录下找到css文件
env/lib/python3.6/site-packages/notebook/static/style/stye.min.css