Jupyter notebook has two components: front-end page of the web browser and the back-end kernel. Data user writes code at the front page then the kernel runs this code and returns the result.
In this article, we will discuss changing the theme in the Jupyter notebook.
What is a Theme in a Jupyter notebook?
A theme in Jupyter notebook defines the appearance of toolbars, buttons, and all visual elements that an interface possesses. By default, the Jupyter notebook has a light theme and it does not include any built-in option to change the theme.
Many users like to have a dark theme. We can change the theme in the jupyter notebook by installing an open-source library i.e., Jupyter themes by ‘Kyle Dunovan’.
How to install the theme in Jupyter theme?
You can install a new theme in the Jupyter notebook by implementing the following steps:
Step 1: Install Jupyter theme library
You can install the Jupyter theme library on your notebook using two methods: conda and pip.
Installation with conda:
Installation with pip:
you can also upgrade the already installed Jupyter notebook themes by using the following command:
Step 2: List available jupyter themes
After installation jupyter theme, you can display a list of available themes by using the following command:
The above command will show the list of available themes.
Step 3: Change jupyter notebook theme
Choose the theme you want to apply and set it with the following given command:
For example, here we applied themes ‘chesterish’ and ‘solarizedl ’respectively.
To complete the process of applying the theme, refresh the page or open a new Python notebook to view changes.
How to restore the original theme in the Jupyter notebook?
To restore the original theme, the following command can be used:
The toolbar, filename, and kernel logo are all by default hidden when the notebook’s theme is changed to one of the above themes. You can enable these options in the Jupyter notebook by using a few commands that we have discussed below:
Enabling other features of the theme
Enable the filename by using this command:
To enable filename and logo use this command:
To enable kernel log use this command:
You can also change the theme and enable all options including the toolbar, filename, logo, and kernel logo in same command line statement:
Font Features in jupyter theme
Jupyter notebook provides the feature of changing code font, font size, notebook font, and notebook font size.
Use the following command to work on the font in the Jupyter notebook:
Options | Arguments |
Code font | Cf |
Code font size | Cfs |
Notebook font | Nf |
Notebook font size | Nfs |
Table 1: Examples of font arguments
You can also use other options to customize in Jupyter themes such as Cell width, Line height, Plotting style, Cursor width, Cursor color, and many more options. It also gives the option to change the plotting style of figures by using the following command:
Conclusion
In this article, we learned how to change the theme in the Jupyter notebook. Jupyter theme is an open-source library to handle the visual presentation of the jupyter notebook. It can make the interface of the jupyter notebook easy and attractive to use. You can easily change your default jupyter notebook theme by following the above steps.