Inserting image into IPython notebook markdown

后端 未结 13 1587
面向向阳花
面向向阳花 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:35

    Files inside the notebook dir are available under a "files/" url. So if it's in the base path, it would be <img src="files/image.png">, and subdirs etc. are also available: <img src="files/subdir/image.png">, etc.

    Update: starting with IPython 2.0, the files/ prefix is no longer needed (cf. release notes). So now the solution <img src="image.png"> simply works as expected.

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

    Change the default block from "Code" to "Markdown" before running this code:

    ![<caption>](image_filename.png)
    

    If image file is in another folder, you can do the following:

    ![<caption>](folder/image_filename.png)
    
    0 讨论(0)
  • 2020-12-07 07:37

    You can find your current working directory by 'pwd' command in jupyter notebook without quotes.

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

    First make sure you are in markdown edit model in the ipython notebook cell

    This is an alternative way to the method proposed by others <img src="myimage.png">:

    ![title](img/picture.png)
    

    It also seems to work if the title is missing:

    ![](img/picture.png)
    

    Note no quotations should be in the path. Not sure if this works for paths with white spaces though!

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

    I am using ipython 2.0, so just two line.

    from IPython.display import Image
    Image(filename='output1.png')
    
    0 讨论(0)
  • 2020-12-07 07:41

    If you want to display the image in a Markdown cell then use:

    <img src="files/image.png" width="800" height="400">
    

    If you want to display the image in a Code cell then use:

    from IPython.display import Image
    Image(filename='output1.png',width=800, height=400)
    
    0 讨论(0)
提交回复
热议问题