我已经运行了Seaborn的clustermap,并将结果保存到名为“ test”的ClusterGrid对象中。但是由于一些未知的原因,尽管“ test”不是空的,但是除非我再次运行它,否则该命令不会显示集群映射。它确实是一个ClusterGrid对象。
那么自从我保存之后,是否有任何简单的方法来显示/绘制ClusterGrid?我尝试了plt.plot,但是没有用。
答案 0 :(得分:0)
键入using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
static class P
{
static void Main()
{
var obj = new SystemInfo();
var bytes = AsBytes(ref obj);
Console.WriteLine(bytes.Length); // 40
}
static Span<byte> AsBytes<T>(ref T value)
=> MemoryMarshal.CreateSpan(
ref Unsafe.As<T, byte>(ref value),
Unsafe.SizeOf<T>());
}
public readonly struct SystemInfo
{
public readonly ulong OemId;
public readonly ulong PageSize;
public readonly ulong ActiveProcessorMask;
public readonly ulong NumberOfProcessors;
public readonly ulong ProcessorType;
}
应该向您显示dir(test)
的方法和属性。 (如果键入seaborn.matrix.ClusterGrid
,则应该看到seaborn.matrix.ClusterGrid
。)列表中有type(test)
和fig
这两个项目。
savefig
将允许您在生成该图的单元下方的任何单元格处再次显示该图,假定test.fig
先前已被调用。因此,如果它在生成单元格中的显示不可靠,请在该单元格的正下方放置一个%matplotlib inline
的单元格,您会看到它。
test.fig
应该将绘图另存为图像文件。您可以使用代码以test.savefig("test_plot.png")
来显示该图像,该图像将被嵌入保存的笔记本中,并随后在静态渲染器中显示。