如何在Jupyter笔记本中显示Seaborn Clustermap Insider [英] how to show seaborn clustermap insider a jupyter notebook
问题描述
我已经运行了Seaborn的clustermap,并将结果保存到名为"test"的ClusterGrid对象中.但是由于某种未知的原因,尽管"test"不是空的,但是除非我再次运行它,否则该命令不会显示集群映射.它确实是一个ClusterGrid对象.
I've run Seaborn's clustermap and saved the result into a ClusterGrid object named "test". However due to some unknown reason that command didn't show the clustermap unless I run it again, although the "test" isn't empty. It is indeed a ClusterGrid object.
那么自从我保存之后,是否有任何简单的方法来显示/绘制ClusterGrid?我尝试了plt.plot,但是没有用.
So is there any simple way to show/plot the ClusterGrid since I've saved it? I tried plt.plot but it didn't work.
推荐答案
键入dir(test)
应该会向您显示seaborn.matrix.ClusterGrid
的方法和属性. (如果键入type(test)
,应该会看到seaborn.matrix.ClusterGrid
.)列表中有两个项目,fig
和savefig
.
Typing dir(test)
should show you methods and attributes of the seaborn.matrix.ClusterGrid
. (seaborn.matrix.ClusterGrid
is what you should see if you type type(test)
.) Among the list are two items, fig
and savefig
.
test.fig
允许您再次显示该图,而不显示生成该图的单元下方的任何单元格,前提是先前调用了%matplotlib inline
.因此,如果它在生成单元格中的显示不可靠,请在该单元格的正下方放置一个test.fig
单元格,您将看到它.
test.fig
will allow you to display the plot again any cell below the one that generated it, assuming %matplotlib inline
was invoked earlier. So if it is displaying unreliably in the generating cell, put a cell with test.fig
right below that one and you'll see it.
test.savefig("test_plot.png")
应将绘图另存为图像文件.您可以使用代码用from IPython.display import Image; Image("test_plot_.png")
显示该图像,该图像将被嵌入保存的笔记本中,并随后在静态渲染器中显示.
test.savefig("test_plot.png")
should save the plot as an image file. You can use code to show that image with from IPython.display import Image; Image("test_plot_.png")
, and that will get embedded in the saved notebook and shown subsequently in static renders.
这篇关于如何在Jupyter笔记本中显示Seaborn Clustermap Insider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!