4 Ways To Insert Image in Jupyter Notebook

4 Ways To Insert Images to Jupyter Notebook

There are 4 ways to add pictures to your Jupyter Notebook.

  1. Using Markdown
  2. Using HTML
  3. Using the IPython.display Module
  4. Using the Matplotlib Library

You can add a picture from your computer, from a website, or even use Python code to show a picture.

1. Using Markdown

You can add a picture by typing the following in a Markdown cell:

![description](picture_path.png)

Replace "description" with a short description of the picture, and "picture_path.png" with the location and name of your picture.

2. Using HTML

You can also add a picture by typing the following in a code cell:

<img src="picture_path.png" alt="description">

Replace "picture_path.png" with the location and name of your picture, and "description" with a short description of the picture.

3. Using the IPython.display Module

You can add a picture by typing the following code in a code cell:

from IPython.display import Image
Image(filename='picture_path.png')

Replace "picture_path.png" with the location and name of your picture.

4. Using the Matplotlib Library

If you're working with data, you can use the matplotlib library to show a picture. Type the following code in a code cell:

import matplotlib.pyplot as plt
from matplotlib.image import imread

img = imread('picture_path.png')
plt.imshow(img)
plt.show()

Replace "picture_path.png" with the location and name of your picture.

Adding Images from a Website

You can also add pictures from a website by copying the URL of the picture and typing the following in a Markdown cell:

![description](http://url/to/picture.jpg)

Replace "description" with a short description of the picture, and "http://url/to/picture.jpg" with the URL of the picture.

Formatting Images

You can change the size and position of your pictures by using HTML code. For example, you can make a picture smaller by typing the following in a Markdown cell:

<img src="path/to/picture.jpg" alt="description" width="300" height="200">

Best Practices for Adding Images

When you're adding pictures to your Jupyter Notebook, remember to:

  • Use the right picture format
  • Resize your pictures
  • Keep your pictures in a separate folder
  • Use descriptive names for your pictures
  • Add alt text for accessibility

Here's a table summarizing these best practices:

Best Practice Description
Use the right picture format Use formats like PNG, JPEG, or GIF.
Resize your pictures Make sure your pictures are not too big.
Keep your pictures in a separate folder This keeps your notebook organized.
Use descriptive names for your pictures This makes it easier to find your pictures.
Add alt text for accessibility This helps people who can't see the picture understand what it's about.

What is Jupyter Notebook?

Jupyter Notebook is a tool that lets you write and share documents that include live code, equations, pictures, and explanations. You can add pictures to your Jupyter Notebook to make it look better and help explain your work.

Why Add Images?

Adding images can help when you're working with data. Pictures can help you understand complex data and explain your findings to others. Also, they make your work more engaging and easier to understand.


Adding pictures to your Jupyter Notebook can make your work look better and help explain your ideas. By following these steps, you can easily add pictures to your Jupyter Notebooks.

Related articles

Ruslan Osipov
Written by author: Ruslan Osipov