如何在 jupyter notebook 中显示 seaborn clustermap insider
how to show seaborn clustermap insider a jupyter notebook
我已经 运行 Seaborn 的 clustermap 并将结果保存到名为 "test" 的 ClusterGrid 对象中。但是由于某些未知原因,该命令没有显示集群图,除非我再次 运行 它,尽管 "test" 不为空。确实是一个ClusterGrid对象。
既然我保存了 ClusterGrid,那么有什么简单的方法可以 show/plot 吗?我试过 plt.plot 但没用。
键入 dir(test)
应该会显示 seaborn.matrix.ClusterGrid
的方法和属性。 (seaborn.matrix.ClusterGrid
是您键入 type(test)
时应该看到的内容。)列表中有两项,fig
和 savefig
。
test.fig
将允许您再次显示生成它的单元格下方的任何单元格,假设之前调用了 %matplotlib inline
。因此,如果它在生成单元格中显示不可靠,请在该单元格正下方放置一个带有 test.fig
的单元格,您就会看到它。
test.savefig("test_plot.png")
应该将绘图保存为图像文件。您可以使用代码通过 from IPython.display import Image; Image("test_plot_.png")
显示该图像,该图像将嵌入保存的笔记本中并随后在静态渲染中显示。
我已经 运行 Seaborn 的 clustermap 并将结果保存到名为 "test" 的 ClusterGrid 对象中。但是由于某些未知原因,该命令没有显示集群图,除非我再次 运行 它,尽管 "test" 不为空。确实是一个ClusterGrid对象。
既然我保存了 ClusterGrid,那么有什么简单的方法可以 show/plot 吗?我试过 plt.plot 但没用。
键入 dir(test)
应该会显示 seaborn.matrix.ClusterGrid
的方法和属性。 (seaborn.matrix.ClusterGrid
是您键入 type(test)
时应该看到的内容。)列表中有两项,fig
和 savefig
。
test.fig
将允许您再次显示生成它的单元格下方的任何单元格,假设之前调用了 %matplotlib inline
。因此,如果它在生成单元格中显示不可靠,请在该单元格正下方放置一个带有 test.fig
的单元格,您就会看到它。
test.savefig("test_plot.png")
应该将绘图保存为图像文件。您可以使用代码通过 from IPython.display import Image; Image("test_plot_.png")
显示该图像,该图像将嵌入保存的笔记本中并随后在静态渲染中显示。