In this article, we will cover how to change the theme in Jupyter Notebook. We will look at what is Jupyter notebook, the themes why we use them, and the different themes available in Jupyter Notebook we will look into examples along with the screenshots to get a better understanding. We will also see how can we customize our theme.
The Jupyter Notebook is the original web application for creating and sharing computational documents that contain live code, equations, visualizations, and narrative text. It offers a simple, streamlined, document-centric experience. Jupyter has support for over 40 different programming languages and Python is one of them.
Change the Theme in Jupyter Notebook
A Jupyter Notebook theme is a pre-defined set of styles like background color, font style, font color, etc. which determines the visual appearance of the Jupyter Notebook interface. By default, Jupyter Notebook uses a light theme, but generally, developers prefer dark themes while working in long coding sessions which helps them to reduce eye strain and makes the visual interface more appealing there are a lot of themes that we discuss later in this article.
Importance of Themes in Jupyter Notebook
- Reduce eye strain: While working in long coding sessions or working in low-light environments they can strain your eyes and hence to reduce eye strain there are different themes available to match the light of your environment.
- Readability: Themes are designed in such a way that enhances the readability of the interface making it easier for color blind and visually impaired persons.
- Personalization: Themes provide a more personal look to the user and make the application more user-friendly.
Jupyter Notebook Themes
To install jupyter notebook themes – open the terminal and run the following command:
pip install jupyterthemes
If you have already install jupyter themes and want to upgrade them run the below command in terminal,
pip install --upgrade jupyterthemes
List all the available themes – To list all the available theme run the following command in terminal,
jt -l
Available themes:
Below are the list that we can use Theme in Jupyter Notebook:
- chesterish
- grade3
- gruvboxd
- gruvboxl
- monokai
- oceans16
- onedork
- solarizedd
- solarizedl
Syntax to Apply Themes in Jupyter Notebook
To apply theme to the jupyter notebook the command syntax is as follows:
!jt -t [theme name]
After applying theme you need to restart the Jupyter Notebook to see the changes.
To reset to the default theme of Jupyter Notebook use the following command,
jt -r
Example 1: Applying Monokai Theme
!jt -t monokai
Example 2: Applying grade3 Theme
!jt -t grade3
Example 3: Applying onedork Theme
!jt -t onedork
Example 4: Applying Chesterish Theme
!jt -t chesterish
Customize Theme in Jupyter Notebook
There are different command line options available in jt command to customize the theme which are as follows:
!jt -t [theme name] -f [font name] -fs [font size] . . .
Command Line option |
Description |
---|---|
-f |
Code Font |
-fs |
Code Font-Size |
-nf |
Notebook Font |
-nfs |
Notebook Font Size |
-tf |
Text/MD Cell Font |
-tfs |
Text/MD Cell Fontsize |
-cellw |
Cell Width |
-lineh |
Line Height |
-cursw |
Cursor Width |
-cursc |
Cursor Color |
-T |
Toolbar Visible |
Example: Applying the different themes simultaneously and also changing the font size, code cell width.
!jt -t monokai -f roboto -fs 16 -cellw 80% -T
- -t monokai sets the theme to Monokai
- –f roboto sets the font to Roboto Mono
- -fs 16 sets the font size to 16 px
- -cellw 80% sets the code cell width to 80% of the screen width
- -T enables the toolbar