【问题标题】:How to edit a JupyterLab theme如何编辑 JupyterLab 主题
【发布时间】:2018-07-05 13:01:03
【问题描述】:

我想编辑 JupyterLab 深色主题,以便可以清楚地阅读内联图上的轴标签。问题示例:

为了解决这个问题,我想将包含图像的输出单元格的背景颜色更改为灰色阴影。我使用 Chrome DevTools 检查网页,找到了 class="p-Widget jp-RenderedImage jp-mod-trusted jp-OutputArea-output" 类。

我注意到我可以通过使用 JupyterLab 浅色主题或在 matplotlib 中使用深色绘图主题来解决这个问题,但是我想直接解决这个问题。我欢迎所有对资源的建议或指导来阅读,这将有助于我理解和解决这个问题。谢谢!

GitHub 上的相关问题:

相关的 SO 问题:

【问题讨论】:

    标签: python themes jupyter-lab


    【解决方案1】:

    要编辑 JupypterLab 主题,您需要更改位于 jupyterlab/packages/[THEME NAME]/style/ 中的文件 variables.css

    您可以检查要更改的 JupyterLab 元素以找出其类。我使用 Chrome DevTools ctrl+shift+i 并单击各种 div 类,直到找到我想要更改的类。

    获得要自定义的 div 类的名称后,将更改添加到 variables.css 文件。这是我所做的更改和结果。

    .jp-RenderedImage {
      background-color: #A4A4A4
    }
    

    您可以使用 JupyterLab 贡献者之一创建的 this gist (where the code in the first cell comes from) 来试验您对 variables.css 文件所做的更改。

    【讨论】:

      【解决方案2】:

      看起来您显示的示例是因为情节的facecolor 是透明的。当我切换到 Jupyter 的黑暗主题时,我注意到我的情节也发生了这种情况。

      以下是更新此 Jupyter 配置的两个参考:

      1. Enable white frames on matplotlib figure/ Disable transparent frames
      2. https://ipython.readthedocs.io/en/stable/config/intro.html

      总而言之,我打开了~/.ipython/profile_default 目录并创建了一个新的ipython_config.py 文件(因为它还不存在)

      cd ~/.ipython/profile_default/
      vi ipython_config.py
      

      在那个文件中,我添加了行

      c = get_config()
      c.InlineBackend.print_figure_kwargs={'facecolor' : "w"}
      

      【讨论】:

      • 也许你的意思是~/.ipython
      猜你喜欢
      • 1970-01-01
      • 2011-06-13
      • 2018-10-03
      • 1970-01-01
      • 2020-03-22
      • 2011-02-21
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      相关资源
      最近更新 更多