如何在Jupyter Notebook中显示文件中的图像? [英] How can I display an image from a file in Jupyter Notebook?
问题描述
我想使用 IPython笔记本作为交互式分析我正在制作的一些基因组图表的方法使用Biopython的 GenomeDiagram
模块。虽然有大量关于如何使用 matplotlib
来获取IPython笔记本内联图形的文档,但GenomeDiagram使用了ReportLab工具包,我认为IPython中的内联图形不支持该工具包。
I would like to use an IPython notebook as a way to interactively analyze some genome charts I am making with Biopython's GenomeDiagram
module. While there is extensive documentation on how to use matplotlib
to get graphs inline in IPython notebook, GenomeDiagram uses the ReportLab toolkit which I don't think is supported for inline graphing in IPython.
然而,我想,解决这个问题的方法是将图/基因组图写出来,然后打开内联图像,这样就可以了结果如下:
I was thinking, however, that a way around this would be to write out the plot/genome diagram to a file and then open the image inline which would have the same result with something like this:
gd_diagram.write("test.png", "PNG")
display(file="test.png")
但是,我无法弄清楚如何做到这一点 - 或者知道是否可能。那么有人知道图像是否可以在IPython中打开/显示?
However, I can't figure out how to do this - or know if it's possible. So does anyone know if images can be opened/displayed in IPython?
推荐答案
由这篇文章,你可以执行以下操作:
Courtesy of this post, you can do the following:
from IPython.display import Image
Image(filename='test.png')
(官方文档)
这篇关于如何在Jupyter Notebook中显示文件中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!