如何在 Jupyter Notebook 中显示文件中的图像? [英] How can I display an image from a file in Jupyter Notebook?
问题描述
我想使用 IPython notebook 作为交互式分析我正在制作的一些基因组图表的一种方式使用 Biopython 的 GenomeDiagram
模块.虽然有大量关于如何使用 matplotlib
在 IPython notebook 中获得内联图形的文档,但 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屋!