我如何自定义Jupyter Notebook进入黑暗模式

数据科学非常简单(DATA SCIENCE MADE SIMPLE)

Jupyter Notebook is an interactive compiler that allows users to create and share documents that contain live code, equations, visualizations, and narrative text. It is a spin-off project from IPython. Almost all of us just know Jupyter Notebook only can compile Python code. Surprise, Jupyter Notebook also can compile Julia, R, Haskell, and Ruby.

Jupyter Notebook是一个交互式编译器,允许用户创建和共享包含实时代码,方程式,可视化效果和叙述文本的文档。 这是IPython的一个衍生项目。 几乎我们所有人都知道Jupyter Notebook仅可以编译Python代码。 令人惊讶的是,Jupyter Notebook还可以编译Julia,R,Haskell和Ruby。

The simplest way to install Jupyter Notebook is by installing via Anaconda. Anaconda gives you a completed package for your Python or R programming. To open it, you just find Jupyter Notebook in your application list. You can also open it via Command Prompt by typing jupyter notebook and press Enter. In Linux, you can install it via pip. You can do the same procedures in Windows to open it, but just type it in Terminal.

安装Jupyter Notebook的最简单方法是通过Anaconda安装。 Anaconda为您提供了用于Python或R编程的完整软件包。 要打开它,只需在应用程序列表中找到Jupyter Notebook。 您也可以通过键入jupyter notebook并按Enter键,通过命令提示符将其打开。 在Linux中,您可以通过pip安装它 您可以在Windows中执行相同的步骤来打开它,而只需在终端中键入它即可。

After you open it, you will be shown a display like this.

打开它后,将显示如下显示。

default themes of jupyter notebook and matplotlib
Jupyter Notebook default themes (Image by Author)
Jupyter Notebook默认主题(作者提供的图像)

At least, there are 4 types of cell you can create, they are

至少可以创建4种类型的单元,它们是

  1. Code, you can run a code in this type of cell.

    代码,您可以在这种类型的单元格中运行代码。

  2. Markdown, you can create an HTML ‘code’ in this cell.

    Markdown,您可以在此单元格中创建HTML“代码”。

  3. Raw NBConvert, this kind of cell is providing you a raw text.

    Raw NBConvert,这种单元格为您提供了原始文本。

  4. Heading, you can create a heading for your interactive file.

    标题,您可以为交互式文件创建一个标题。

This is the example of Code cell type that run of R-code and Python-code. The indicator is shown at the top right corner. You can see symbol of R and Python on it.

这是运行R代码和Python代码的代码单元格类型的示例。 该指示器显示在右上角。 您可以在上面看到R和Python的符号。

Image for post
Image for post
Code cell of R (left panel) and Python (right panel) language (Image by Author)
R(左面板)和Python(右面板)语言的代码单元(作者提供的图像)

If you want to be guided on how to install R in Jupyter Notebook, you can leave a comment below.

如果您想获得有关如何在Jupyter Notebook中安装R的指导,可以在下面留下评论。

This is the Markdown cell. I show you the example of enhancing your Jupyter Notebook by creating a nice cell using HTML. The first line will produce a centered title and the second line produce two paragraphs followed by a picture and its link.

这是Markdown单元。 我展示了通过使用HTML创建漂亮的单元格来增强Jupyter Notebook的示例。 第一行将产生居中标题,第二行将产生两个段落,然后是图片及其链接。

markdown jupyter notebook
Markdown Jupyter Notebook (Image by Author)
Markdown Jupyter笔记本(图片由作者提供)

After you run two cells above, you will get results like this

在上面运行两个单元格后,您将获得如下结果

markdown jupyter notebook
Markdown Jupyter Notebook (Image by Author)
Markdown Jupyter笔记本(图片由作者提供)

It’s pretty cool!!!

它太酷了!!!

Next, is the example of Raw NBConvert cell type. Here it is.

接下来,是Raw NBConvert单元格类型的示例。 这里是。

Jupyter notebook cell
Raw NBConvert Jupyter Notebook cell (Image by Author)
原始NBConvert Jupyter笔记本单元格(作者提供的图像)

There is no result expect just a text. I think, Raw NBConvert is similar with comment in Python but in interactive version.

没有结果,只是文本。 我认为Raw NBConvert与Python中的注释类似,但在交互式版本中。

The last is Heading cell type, here is the example

最后是标题单元格类型,这里是示例

Jupyter notebook cell heading
Heading cell type in Jupyter Notebook (Image by Author)
Jupyter Notebook中的标题单元格类型(作者提供的图像)

The cell will give you a result as follows

该单元格将为您提供如下结果

Jupyter notebook cell heading
Heading cell type in Jupyter Notebook (Image by Author)
Jupyter Notebook中的标题单元格类型(作者提供的图像)

You can create a different size of your heading with Markdown cell type as mentioned before.

您可以使用前面提到的Markdown单元格类型来创建不同大小的标题。

This article will guide you to change the Jupyter Notebook theme. If you inspect some pictures above, you will realize that the default themes of Jupyter Notebook is white. Yups, I will give you a tutorial to change it into dark mode.

本文将指导您更改Jupyter Notebook主题。 如果您查看上面的某些图片,您将意识到Jupyter Notebook的默认主题是白色。 是的,我将给您一个教程,将其更改为黑暗模式。

First, you need to install jupyter notebook themes, using this code

首先,您需要使用以下代码安装jupyter笔记本主题

# install jupyterthemes
pip install jupyterthemes

# upgrade to latest version
pip install --upgrade jupyterthemes

If you face some problems, the simplest solution is upgrading your Jupyter Notebook. If you got a problem with permissions, just change the permission. Please leave a comment if you got another problem. Maybe, I can give you some alternatives.

如果遇到问题,最简单的解决方案是升级Jupyter Notebook。 如果您遇到权限问题,只需更改权限即可。 如果您遇到其他问题,请发表评论。 也许我可以给你一些选择。

After installing jupyterthemes, you can read the documentation by writing

安装jupyterthemes之后,您可以通过编写以下内容阅读文档

jt -h

in your Terminal or Command Prompt.

在终端或命令提示符中。

There are 9 different themes that is provided by jupyterthemes, they are chesterish, grade3, gruvboxd, gruvboxl, monokai, oceans16, onedork, solarizedd, and solarizedl. You can check the list by writing this code

jupyterthemes提供了9个不同的主题,它们分别是chesterche,3级,gruvboxd,gruvboxl,monokai,oceans16,onedork,solarized和solarizedl。 您可以通过编写此代码来检查列表

jt -l

It will give you this list

它会给你这个清单

jupyter notebook list themes
List of themes in jupyterthemes (Image by Author)
jupyterthemes中的主题列表(作者提供的图片)

To change your Jupyter Notebook themes, you can write jt -t name_themes

要更改Jupyter Notebook主题,可以编写jt -t name_themes

jt -t chesterish

After do it, you can refresh your Jupyter Notebook file. Here is the example of all of themes provided by jupyterthemes.

完成后,您可以刷新Jupyter Notebook文件。 这是jupyterthemes提供的所有主题的示例。

Image for post
Image for post
Image for post
Left: chesterish themes, :彻斯特主题, middle: onedork onedork , Right: oceans16. ,右:海洋16。

If you are not interested in dark mode, you can try this following themes

如果您对黑暗模式不感兴趣,可以尝试以下主题

Image for post
Image for post
Image for post
Left: gruvboxd themes, :gruvboxed主题, middle: 中间monokai monokai , Right: solarizedd. ,右:solarized。

Or this light mode themes

还是这个灯光模式的主题

Image for post
Image for post
Image for post
Left: grade3 themes, :3年级主题, middle: solarizedl 中间:solarizedl , Right:gruvboxl. ,右:gruvboxl。

Just choose your favorite themes :D.

只需选择您喜欢的主题即可:D。

To change it into default themes, you can write this code

要将其更改为默认主题,您可以编写以下代码

jt -r

Here is the default themes.

这是默认主题。

jupyter notebook themes
Default Jupyter Notebook themes (Image by Author)
默认的Jupyter Notebook主题(作者提供的图像)

If you think this article is over here. No!! :D. I will give another cool method to change the Matplotlib parameters using jupyterthemes.

如果您认为本文已结束。 没有!! :D 我将提供另一个很酷的方法,使用jupyterthemes更改Matplotlib参数。

jupyterthemes provide you some cool fonts to be applied in your plot, they are

jupyterthemes为您提供了一些可以在您的情节中应用的很酷的字体,它们是

Image for post
jupyterthemes (Source: jupyterthemes提供的字体(来源: Dunovank) Dunovank )

How to use it, here it is (source: Dunovank)

如何使用它,就在这里(来源: Dunovank )

That’s all. Try all of the possibilities. Cheers.

就这样。 尝试所有可能性。 干杯。

翻译自: https://medium.com/@leaftech/how-can-i-customize-jupyter-notebook-into-dark-mode-7985ce780f38

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值