[英]Resize the image in jupyter notebook using markdown
我想在 Jupyter 筆記本中添加圖像,並且我想要具有特定的高度和寬度。 當我嘗試使用添加圖像時
![](img.png)
該代碼正在添加完整的圖像,但根據圖像尺寸,我無法控制它。 我嘗試使用![](img.png =200x100)但是圖像沒有出現。
有人知道添加具有預先指定尺寸的圖像的方法嗎?
可以直接使用html
<img src="image.JPG" alt="Drawing" style="width: 200px;"/>
如果您通過將圖像插入降價來附加圖像,如下所示:
![Screenshot.png](attachment:Screenshot.png)
這些attachment
鏈接不工作:
<img src="attachment:Screenshot.png" width="500"/>
這樣做。 這確實有效。 只需添加 div 括號:
<div>
<img src="attachment:Screenshot.png" width="500"/>
</div>
希望這可以幫助!
PS我正在使用jupyter_core-4.4.0
和 jupyter notebook。
您需要使用 Mark 向您展示的 HTML,因為您不能使用![](img.png)
語法來做到這一點。 從約翰格魯伯的網站:
在撰寫本文時,Markdown 沒有用於指定圖像尺寸的語法; 如果這對您很重要,您可以簡單地使用常規 HTML 標簽。
您還可以使用IPython.display
Image
模塊
https://ipython.org/ipython-doc/3/api/generated/IPython.display.html#IPython.display.Image
例如
from IPython.display import Image
Image(url='https://www.maxpierini.it/ncov/pics/ITA.png', width=200)
如果圖像是本地文件,請使用filename=
而不是url=
。
我在 JupyterHub 實例中使用 JupyterLab,其他答案對我不起作用。 我已經用我的圖像周圍的<div>
解決了這個問題。 這是我的 400px 寬度和右對齊的圖像:
<div style="max-width:400px;margin-left: auto; margin-right: 0;">
![My Image alt text](image.jpg)
</div>
將此“代碼”更改為“Markdown”,就像屏幕截圖一樣。 稍后添加
<div> <img src="bar graph.png" alt="Drawing" style="width: 400px;"/></div>
你完成了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.