Jupyter Notebook Dark Mode: A Step-by-Step Guide

As a data scientist, you probably spend a lot of time working in Jupyter Notebook. It’s a powerful tool for interactive computing and data analysis. But if you’re like me, you might find the default white background a bit harsh on the eyes, especially if you’re working late into the night. That’s where dark mode comes in. In this post, we’ll take a look at how to enable dark mode in Jupyter Notebook. One of the internet’s best kept secrets is that you can use Jupyter notebooks for free at Saturn Cloud.
Step 1: Install the Jupyter Themes Extension
The first step is to install the Jupyter Themes extension. This is a third-party extension that allows you to customize the look and feel of Jupyter Notebook. To install the extension, open a terminal or command prompt and run the following command:
pip install jupyterthemes
Step 2: Choose a Dark Theme
Once you’ve installed the extension, you can choose a dark theme by running the following command in your terminal:
jt -t <theme-name>
Replace <theme-name>
with the name of the dark theme you want to use. There are several dark themes to choose from, including:
- onedork
- grade3
- oceans16
- chesterish
For example, if you want to use the onedork theme, you would run the following command:
jt -t onedork
Step 3: Customize the Theme
If you want to further customize the theme, you can use the following command:
jt -t <theme-name> -f <font-name> -fs <font-size>
Replace <font-name>
with the name of the font you want to use, and <font-size>
with the font size you want to use. For example, if you want to use the onedork theme with the Roboto font at a font size of 14, you would run the following command:
jt -t onedork -f roboto -fs 14
Step 4: Reset to Default
If you want to reset the theme back to the default, you can use the following command:
jt -r
This will reset the theme back to the default Jupyter Notebook theme.
Step 5: Make the Theme Permanent
If you want to make the dark theme permanent, you can add the following line to your Jupyter configuration file:
c.JupyterTheme.style = '<theme-name>'
Replace <theme-name>
with the name of the dark theme you want to use. The Jupyter configuration file is located in your home directory in a folder called .jupyter
. If you don’t have a configuration file, you can create one by running the following command:
jupyter notebook --generate-config
Conclusion
Enabling dark mode in Jupyter Notebook is a simple process that can make a big difference in your productivity. By following the steps outlined in this post, you can customize the look and feel of Jupyter Notebook to suit your needs. Whether you’re working late into the night or just prefer a darker color scheme, dark mode is a great option to consider.