显示图像jupyter笔记本对齐的中心 [英] display image jupyter notebook aligned centre
本文介绍了显示图像jupyter笔记本对齐的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码在与html转换兼容的Jupyter笔记本中插入图像:
I am using the following code to insert an image in Jupyter notebook which is compatible with html conversion:
从IPython.display导入图像
from IPython.display import Image
图片(filename ="picture.jpg")
Image(filename="picture.jpg")
这很好用,除了它保持左对齐而且我需要它居中对齐. 有什么方法可以将其设置为正确对齐?
This works nicely except the fact that it is left aligned and I need it centre/middle aligned. Is there any method that I can set it to be aligned correctly?
推荐答案
您可以将单元格设置为markdown
并使用以下内容:
You can set the cell as markdown
and use this content:
<img src="picture.jpg" width="240" height="240" align="center"/>
然后运行它.
Edit1
或者,您可以将code
单元格与此代码一起使用:
Alternatively, you can use a code
cell with this code:
from IPython.display import HTML
html1 = '<img src="picture.jpg" width="240" height="240" align="center"/>'
HTML(html1)
这篇关于显示图像jupyter笔记本对齐的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文