Inserting image into IPython notebook markdown

后端 未结 13 1586
面向向阳花
面向向阳花 2020-12-07 06:51

I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible,

相关标签:
13条回答
  • 2020-12-07 07:26

    Most of the answers given so far go in the wrong direction, suggesting to load additional libraries and use the code instead of markup. In Ipython/Jupyter Notebooks it is very simple. Make sure the cell is indeed in markup and to display a image use:

    ![alt text](imagename.png "Title")
    

    Further advantage compared to the other methods proposed is that you can display all common file formats including jpg, png, and gif (animations).

    0 讨论(0)
  • 2020-12-07 07:26

    For those looking where to place the image file on the Jupyter machine so that it could be shown from the local file system.

    I put my mypic.png into

    /root/Images/mypic.png
    

    (that is the Images folder that shows up in the Jupyter online file browser)

    In that case I need to put the following line into the Markdown cell to make my pic showing in the notepad:

    ![My Title](Images/mypic.png)
    
    0 讨论(0)
  • 2020-12-07 07:27

    minrk's answer is right.

    However, I found that the images appeared broken in Print View (on my Windows machine running the Anaconda distribution of IPython version 0.13.2 in a Chrome browser)

    The workaround for this was to use <img src="../files/image.png"> instead.

    This made the image appear correctly in both Print View and the normal iPython editing view.

    UPDATE: as of my upgrade to iPython v1.1.0 there is no more need for this workaround since the print view no longer exists. In fact, you must avoid this workaround since it prevents the nbconvert tool from finding the files.

    0 讨论(0)
  • 2020-12-07 07:28

    I put the IPython notebook in the same folder with the image. I use Windows. The image name is "phuong huong xac dinh.PNG".

    In Markdown:

    <img src="phuong huong xac dinh.PNG">
    

    Code:

    from IPython.display import Image
    Image(filename='phuong huong xac dinh.PNG')
    
    0 讨论(0)
  • 2020-12-07 07:30

    Getting an image into Jupyter NB is a much simpler operation than most people have alluded to here.

    1) Simply create an empty Markdown cell. 2) Then drag-and-drop the image file into the empty Markdown cell.

    The Markdown code that will insert the image then appears.

    For example, a string shown highlighted in gray below will appear in the Jupyter cell:

    ![Venus_flytrap_taxonomy.jpg](attachment:Venus_flytrap_taxonomy.jpg)

    3) Then execute the Markdown cell by hitting Shift-Enter. The Jupyter server will then insert the image, and the image will then appear.

    I am running Jupyter notebook server is: 5.7.4 with Python 3.7.0 on Windows 7.

    This is so simple !!

    0 讨论(0)
  • 2020-12-07 07:31

    Last version of jupyter notebook accepts copy/paste of image natively

    0 讨论(0)
提交回复
热议问题