Jupyter Notebook 中的暗模式图 - Python

evi*_*cta 1 python jupyter-notebook

我正在使用 Jupyter Notebook,我目前正在使用 JupyterThemes 的深色日光主题。

我注意到我的绘图不是在黑暗模式下,文本在日光化背景上仍然是黑色且无法阅读。JupyterThemes 的自述文件建议在 ~/.ipython/profile_default/startup/startup.ipy 中创建一个 startup.ipy 并编写

# import jtplot submodule from jupyterthemes
from jupyterthemes import jtplot

# currently installed theme will be used to
# set plot style if no arguments provided
jtplot.style()
Run Code Online (Sandbox Code Playgroud)

我已经创建了这个文件,但没有任何改变。我也尝试过遵循本指南(https://medium.com/@rbmsingh/making-jupyter-dark-mode-great-5adaedd814db)但我的情节再次没有改变。

有什么帮助吗?我喜欢在 Jupyter Notebook 中使用暗模式,我希望有清晰的图。

Ant*_*nne 5

当我在暗模式下工作时,我在 matplotlib 导入之后添加下面的样式行,并且笔记本中的所有图形都使用黑色背景和白色文本进行格式化。

import matplotlib.pyplot as plt  
plt.style.use('dark_background')
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助


小智 5

我找到了一种解决方案,可以稍微扩展绘图画布,以便 x 和 y 刻度线可见。

plt.style.use('default')在笔记本中导入 matplot lib 模块后需要添加一行。

看看我的蜱虫之前在画布之外。

添加该行后,刻度线已添加到画布本身,无需进一步修改。

正如您在上图中看到的,这将拉动画布中的 x 和 y 刻度以使其可见,而无需更改或修改刻度或绘图颜色,这将使您更轻松地与其他人协作工作。